The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Multiple reference data calculations
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

L007

12 Posts

Posted - 07/15/2008 :  10:58:48 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
hello,

I´m using Origin 7.5. I have multiple sets of curves to be subtracted, so wanted to build one graph with both terms Y1 and Y2 (using Origin notation: Y = Y1 - Y2), where Y1 and Y2 would be grouped in sequence in two separate groups. I wanted to calculate Y, placing the results in new worksheets (otherwise Origin wouldn´t keep the original data, that will be used further on).

I figured out how to subtract two datasets with Labtalk, but I don´t know how to select the curves for performing the calculations! In other words, I don´t know how to start heheh

I appreciate any help!

Shirley_GZ

China
Posts

Posted - 07/15/2008 :  11:04:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If you want to apply a subtration operations on plotted data, you can select Analysis:Simple Math or Analysis: Subtract: Reference Data to open the Math on/between Dataset Dialog Box when the graph is active.

By the way, Origin subtracts each value in Y1 from the corresponding value in Y2 and saves and plots the result as Y1 after clicking ok. If you want to keep the Original data, you should duplicate the data of Y1 and Y2 to a new worksheet before you do this function.

If you want to write a labtalk script, I think there will be more presumptions you need to consider, like that if the number of points of these two curves are different, you need apply the interpolation.So I think the way from GUI is more easy.

More information about this function you can see here:
Help: Analysis: Basics > Math Operations on Plotted Data > Performing Math Operations

Shirley Tian

Originlab Technical Service Team

Edited by - Shirley_GZ on 07/16/2008 05:36:06 AM
Go to Top of Page

L007

12 Posts

Posted - 07/16/2008 :  08:40:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Shirley,

I know I can use the Analysis -> Simple Math, but the problem is that I have to perform several dozens of calculations several dozens of time, and the dialog in Origin 7.5 is not user friendly when you have more than some hundreds of columns in a project. That´s why I need an script to automate this process of calling this procedure.

I know I can call this operation with the following syntax in labtalk:

dataset1 +-O dataset2a

What I´m not familiar with labtalk is how to identify select whithin a graph dataset1 and dataset2a as I specified before: dataset1 from group1 and dataset2 from group2, where dataset2a is a copy from the original dataset dataset2.
Go to Top of Page

L007

12 Posts

Posted - 07/16/2008 :  6:05:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Well, I managed to put this code to work:

loop(ii,1,count)
{
lay -s 1;
%A=%(ii, @D);
lay -s 2;
%B=%(ii, @D);
%B +-O %A;
}

now,is it possible to substitute the lay command to select the datasets by a similar command that deals with datasets whithin a group of curves?
Go to Top of Page

larry_lan

China
Posts

Posted - 07/16/2008 :  10:35:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi:

Do you mean you want to perform some calculation on all the curves in a layer? If so, I think the doc -e D command should work. For example, this script Add tow curves in the active layers:


%A = %C; // Get Active dataset name;
doc -e D
{
	If ( %A != %C )
	{
		// All curves in the active layer will plus %A (Except %A)
		%C +-O %A;
	}
}


Hope this helps.

Thanks
Larry
OriginLab Technical Services
Go to Top of Page

L007

12 Posts

Posted - 07/17/2008 :  08:08:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Not exactly. If I understood correctly, your scrpit assumes that you have:

Layer1
curve1
curve2
...
curven

active dataset: curvek

then you will calculate:

Layer1
curve1+curvek
curve2+curvek
...
curven+curvek

The script I´ve posted does this; given


Layer1 Layer2
curve11 curve21
curve12 curve22
... ...
curve1n curve2n

it gives

Layer2
curve11+curve21
curve12+curve22
... ...
curve1n+curve2n

but I want to modify that to:

Initial data

Layer1
Group1 Group2
curve11 curve21
curve12 curve22
... ...
curve1n curve2n

Calculated
Layer1
Group3
curve11+curve21
curve12+curve22
... ...
curve1n+curve2n


Go to Top of Page

larry_lan

China
Posts

Posted - 07/22/2008 :  10:17:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi:


We don't have a property to distinguish curves in different groups. Sorry about that.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000