T O P I C R E V I E W |
SteffenG |
Posted - 06/16/2011 : 08:22:02 AM Origin 8.5.0G SR1 b161 WinXP
Hi all,
after upgrading to Origin 8.5.0 some of my scripts don't run anymore. Under 8.1 everything runs smooth. Here is the problem:
The script should run over several spectra. These spectra should be weighted with a second static spectra. Because of different x-coordinates I use interpolation. For interpolation I use the aa(bb_x)-construction. This means values from aa are interpolated to fit to x-coordinates defined by bb_x. With 8.5.0 I get the strange behaviour that inside a for-loop-construction the interpolation is done only ones. After the first iteration aa could be changed (redirected range notation) but the results of the interpolation do not change. Here is the code:
range spektren = [spektren]1!;//worksheet with original spectra; range augex = [Tvis]2!col(1);//x-coordinates of static spectrum; range augey = [Tvis]2!col(2);//y-coordinates of static spectrum; sum(augey);//some simple calculation; norm_faktor=sum.total;//hold the sum for later usage; ii=2;//count variable; for (jj=2;jj<=spektren.ncols;jj++){ range reflexspec = %(spektren)col($(jj));//defines the actual spectrum; range Tvisy = col(2)[$(ii-1)];//defines a cell in the actual worksheet to hold the result of calculation; range temp = [Tvis]2!col(temp);//defines a column for temporary use; mark -m temp;//clears the temporary column; temp = reflexspec(augex)*augey;//calculates the weighted spectrum with interpolated values of reflexspec; sum(temp);//some simple calculation; Tvisy = sum.total/Norm_Faktor;//some simple calculation; ii++; };
Please be aware that the code was running very well under Origin 8.1. Within 8.5.0 I get always the result from the first spectrum for all other spectra. If I use the code without the interpolation I get for each spectra different results as expected. Without the interpolation the respective code (marked red) looks like temp = reflexspec*augey;//calculates the weighted spectrum without interpolation;
I have no idea where this behaviour comes from. I am open for every suggestion to solve this issue.
Best regards, Steffen
|
2 L A T E S T R E P L I E S (Newest First) |
SteffenG |
Posted - 06/17/2011 : 04:47:20 AM Thanks Greg,
I upgraded to Origin 8.5.1 SR 2. Now the problem is gone.
Best regards, Steffen
|
greg |
Posted - 06/16/2011 : 1:38:37 PM There is a bug in 8.5.0 when using a range as a lookup function within a loop. This was fixed in 8.5.1 SR1.
As a workaround, you can use the nameof function to return the range Short Name and use that as your lookup function:
%A = nameof(reflexspec)$; temp = %A(augex)*augey;
|