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
 Forum for Origin C
 multiplication of datasets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

slooff

Netherlands
Posts

Posted - 08/28/2006 :  09:36:08 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System:Windows 2000

Hello to all,

It sounds very basic, but I cannot find the answer.
I want to multiply two datasets data61 and am15, and put the result in a new dataset. The x-values are given in column A and are different for both datasets. The y-values are given in column B.

How do I address these datasets in C and how can I perform the multiplication?

Thanks in advance.
Best regards,

Lenneke

zachary_origin

China
Posts

Posted - 08/28/2006 :  12:04:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Lenneke,


I do not know what your meaning of multiply two datasets.
But for how to manipulate the elements of the datasets, you can see the following example, which adds x and y of the two datasets respectively and stored in a new dataset.


void ManipulateDataset()
{

Dataset dsAX("data1_a"), dsAY("data1_b");//data1 is the name of workbook for the first dataset, column A as x and column B as Y.
Dataset dsBX("data2_a"), dsBY("data2_b");//data2 is the name of workbook for the second dataset, column A as x and column B as Y.
Dataset dsCX("data3_a"), dsCY("data3_b");//data3 is the name of workbook for the results

int nSize = dsAX.GetSize()> dsBX.GetSize()? dsBX.GetSize(): dsAX.GetSize();

dsCX.SetSize(nSize);//Set the size of data3 as the min of data1 and data2
dsCY.SetSize(nSize);

//here is to show how to access each element of the dataset,
//in fact, you can simply use
//dsCX = dsAX + dsBX;
// to add two columns.

for(int ii = 0; ii<nSize; ii++)
{
dsCX[ii] = dsAX[ii] + dsBX[ii];// x3 = x1 + x2;
dsCY[ii] = dsAY[ii] + dsBY[ii];// y3 = y1 + y2;
}

}





For more information about dataset, please reference to Help > Programming > Origin C Language Reference > Classes > Dataset, vector and vectorbase. There are many detailed examples you can learned from.




Zachary
OriginLab GZ Office
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/28/2006 :  2:51:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Lenneke,

Seems to me you want to multiply two curves that have different X values. While it is possible to evaluate the Y values of one curve at the X values of the other and then multiply directly, it's easier in this case to use LabTalk's *-O operation...

Worksheet wks1("data61"),wks2("am15"),wks3;
wks3.CreateCopy(wks1);
Dataset ds3(wks3,1),ds2(wks2,1);
LT_execute(ds3.GetName() + " *-O " + ds2.GetName());

Mike Buess
Origin WebRing Member
Go to Top of Page

slooff

Netherlands
Posts

Posted - 08/29/2006 :  03:37:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Mike,

Thanks, that works indeed!
This helps me a lot.

Regards,

Lenneke
Go to Top of Page

vicore

1 Posts

Posted - 06/28/2011 :  05:24:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

sorry for the maybe much too easy question, but how where can I write and run the code? The "Window>Script Window"-window doesnt execute the command. Thanks for your help.

Best Regards
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