Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
U Acevedo
Posted - 10/06/2020 : 08:21:38 AM Origin Ver. and Service Release (Select Help-->About Origin): 2020 Operating System:Win
Hello,
My script becomes exponentially slower when increasing the number of columns to fit with nlfit X-function.
I need to fit several columns (more than 3000) with the same fitting function but with different starting parameters depending on a certain condition.
I used the nlfit X-function inside a loop which sets different starting parameters depending on the condition variable: Wtype. My script takes about 10 min fitting the first 500 cols, then for the next 500 it takes more than 30 min and so on. I think that the problem comes from the memory management after each nlfit loop but i am a newbie and I dont know how to optimize it...
Here is my code:
//Declaration of start/end columns to fit win -a Book1; int start = 2; int end =wks.nCols; range Fitted_X_ROIii=col(Fitted_X_ROIii); range Fitted_Y_ROIii=col(Fitted_Y_ROIii);
// Create a sheet to collect the fitted curves newsheet name:="FitCurves" labels:="Fitted X" active:=0; range xfit = FitCurves!wcol(1); xfit = {0:0.36036036036036:360}; int i; loop(i, start, end) { range cc = FitCurves!wcol(i); cc[L]$ = "Fitted Y"; cc[C]$ = "ROI$(i-1)"; }
// Create a result sheet to collect the fit result newsheet name:="Results" labels:="Plot|delta|error_delta|d15|error_d15|c_param|Rsq|Wtype|Alpha_max" active:=0; range rPlot = Results!col(Plot); range rd = Results!col(delta); range rerror_d = Results!col(error_delta); range rd15 = Results!col(d15); range rerror_d15 = Results!col(error_d15); range rc = Results!col(c_param); range rRsq = Results!col(Rsq); range rWtype = Results!col(Wtype); range alphamax = Results!col(Alpha_max);
It is normal the processing speed gets slow when more columns get involved. Can you split your worksheet and process 500 columns in one project each time?