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
 convert worksheet to matrix with regular format
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

vistec

Posts

Posted - 03/09/2006 :  03:32:37 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5 SR 4
Operating System: Win XP Service Pack 2

Hello All,

I want to convert a worksheet to a matrix using the regular XYZ to matrix format. Converting the matrix in Origin (edit/convert to matrix / regular xyz ) works well.
Now I want to do this by using Labtalk.
I used the following Labtalk code from the Labtalk help:

mat.wksname$ = %H;
win -T M;
mat.matname$ = %H;
mat.xcol = 1;
mat.ycol = 2;
mat.zcol = 3;

//Convert the XYZ data to a matrix

mat.xyz2m();

The problem is that only an empty Matrixsheet is created.
The columns in the worksheet are specified correctly as x,y and z.
So I can 't find the mistake. Perhaps there is a better opportunity to solve the problem in Origin C?

Thanks

vistec

Mike Buess

USA
3037 Posts

Posted - 03/09/2006 :  08:46:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi vistec,

Your script works perfectly for me with a regular XYZ wks regardless of the actual column designations. Possibly your wks is not as regular as you think. If I make a slight change to one value in the X or Y column the script fails even though the corresponding menu command still works. The menu command probably tests and smooths the data prior to conversion. You can find out exactly what the menu command does by pressing Ctrl+Shift while you select the menu item.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 03/09/2006 08:49:44 AM
Go to Top of Page

vistec

Posts

Posted - 03/09/2006 :  10:20:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike for your help.

I changed my code into the following.
Now I call an origin c function:

run_convert_regular_xyz_to_matrix();

from the Origin C help, in Labtalk.

Code:

void run_convert_regular_xyz_to_matrix()
{
Dataset dsX("stopugo_PositionX"), dsY("stopugo_PositionY"),
dsZ ("stopugo_mRX");

vector vecX(dsX), vecY(dsY), vecZ(dsZ);

MatrixLayer ml;
ml.Create();
Matrix matData(ml);

double dXmax, dXmin;
vecX.GetMinMax(dXmin, dXmax); //Get the maximum and minimum
values of X
double dYmax, dYmin;
vecY.GetMinMax(dYmin, dYmax); //Get the maximum and minimum
values of Y
convert_regular_xyz_to_matrix(vecX, vecY, vecZ, matData,
dXmin, dXmax, dYmin, dYmax);
}

The code works well. Nevertheless in my opinion this code and the
Labtalk code should cause the same result. Maybe there is a stronger difference between a Labtalk command and its corresponding origin c code than it seems to for me be at first glance?

Edited by - vistec on 03/09/2006 10:21:18 AM

Edited by - vistec on 03/09/2006 10:23:03 AM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/09/2006 :  10:54:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I think LabTalk's mat.xyz2m() method is equivalent to setting the bCheckData argument to false in convert_regular_xyz_to_matrix(). In other works, your Origin C function might also fail if you use this...

convert_regular_xyz_to_matrix(vecX, vecY, vecZ, matData,
dXmin, dXmax, dYmin, dYmax,false);

Mike Buess
Origin WebRing Member
Go to Top of Page

vistec

Posts

Posted - 03/10/2006 :  03:30:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks Mike
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