Author |
Topic |
|
ticofiz
United Kingdom
21 Posts |
Posted - 12/08/2016 : 11:52:00 PM
|
Origin Ver. 9.1 and Service Release 3 Operating System:MS W7
Hello,
I try to subtract one Worksheet from another, both Worksheets being in the same Workbook. Could you please tell me the syntax to do that? I have found one similar topic in this forum but it is not clear for me how to do that.Here is the link to the data I am trying to analyze https://www.dropbox.com/s/kyvfzv1s1t41ut8/A1.ogw?dl=0.
Many thanks, Constantin |
Edited by - ticofiz on 12/08/2016 11:53:04 PM |
|
AmandaLu
439 Posts |
Posted - 12/09/2016 : 03:33:03 AM
|
Hi,
I cannot download your data. But I suppose you want to subtract columns in sheet2 with the corresponding columns in sheet1? Please try highlight all columns in worksheet 3, right click and select Set Multiple Column Values. In the dialog that opens, set formula as follow:
Thanks, Amanda OriginLab Technical Service
|
Edited by - AmandaLu on 12/09/2016 03:36:45 AM |
|
|
ticofiz
United Kingdom
21 Posts |
Posted - 12/09/2016 : 03:34:21 AM
|
I have managed to find something like this:
int colnum = wks.ncols; // Number of columns for calculation
for ( ii = 1; ii <= colnum; ii++)
{
vmathtool -r 2 ix1:=[s]1!wcol(ii) operator:=sub operand:=data ix2:=[s]2!wcol(ii) ox:=[Results]<active>!<new>;
}
But for some reason it is very slow. It has been more than 6 minutes and it hasn't finished yet. I have 100's of sheets to analyze, any idea how to speed things up?
Thanks, Constantin |
|
|
ticofiz
United Kingdom
21 Posts |
Posted - 12/09/2016 : 03:36:54 AM
|
Sorry Amanda, I cannot see the code that you posted. |
|
|
AmandaLu
439 Posts |
Posted - 12/09/2016 : 03:45:56 AM
|
Could you please refresh this post? I updated the image.
Thanks, Amanda OriginLab Technical Service |
|
|
ticofiz
United Kingdom
21 Posts |
Posted - 12/10/2016 : 4:58:30 PM
|
Thank you for your help. It is much simpler the method you showed. But it is still very slow. The same operation done in Python or Matlab takes 1-2 seconds compared with 10+ minutes for Originlab.
Thanks, Constantin |
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 12/12/2016 : 2:36:32 PM
|
Hi Constantin,
In Origin, the most optimized internal code could be achieved by using the unary assignment operator "-=". In my experiment, this way is 14 times faster than your code with vmathtool x-function. See the sample result below://///////////////////////////////////////////
int colnum = wks.ncols;
for ( ii = 1; ii <= colnum; ii++) {
vmathtool -r 2 ix1:=[Book1]1!wcol(ii) operator:=sub operand:=data ix2:=[Book1]2!wcol(ii) ox:=[Results]<active>!<new>;
}
//==> Lap Time = 4.165sec
/////////////////////////////////////////////
for ( ii = 1; ii <= colnum; ii++) {
range r1=[Book1]1!wcol(ii);
range r2=[Book1]2!wcol(ii);
range r3=[Book1]3!wcol(ii);
r3=r2-r1;
}
//==> Lap Time = 1.857sec
//==> 2.2 times faster than using vmathtool
/////////////////////////////////////////////
for ( ii = 1; ii <= colnum; ii++) {
range r1=[Book2]1!wcol(ii);
range r2=[Book2]2!wcol(ii);
r2-=r1;
}
//==> Lap Time = 0.296sec
//==> 14 times faster than using vmathtool
///////////////////////////////////////////// Hope this helps.
--Hideo Fujii OriginLab |
|
|
ticofiz
United Kingdom
21 Posts |
Posted - 12/12/2016 : 2:59:09 PM
|
Thank you, Hideo, for the code. Very useful. Do you know something similar that make the operation "find peaks" a bit faster? Currently it take around 90 minutes to analyze a worksheet with 2200 columns and 150 rows. I use "Batch Peak Analysis Using Theme".
Thanks, Constantin |
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 12/12/2016 : 5:13:42 PM
|
Hi Constantin,
> make the operation "find peaks" a bit faster?
May or may not speed up(or even possibly slower), but could you please just experiment to run the Quick Peaks gadget such that - Make plots from all columns, open Quick Peaks, expand full X range (there is a shortcut for it), then choose "New Output for All Curves" flyout.
Let me know the result of this experiment.
--Hideo Fujii OriginLab |
Edited by - Hideo Fujii on 12/12/2016 5:57:59 PM |
|
|
|
Topic |
|