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
 Origin Forum
 Splitting rows into multiple columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

thentangler

USA
Posts

Posted - 08/05/2010 :  02:46:46 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 8.1 and Service Release 3 Operating System: Win 7

Hi,
Im having problem with this labtalk script.
I have a whole list of data in one collumn where measurements have been done in steps of 201 points. I want to separate this long column of 1005 rows into 5 columns of 201 rows of data. (1005/201=5)
I wrote a Labtalk script, but for some reason it gives me a

LabTalk expression error: 5
Error: GETSIZE()

This is the script:
r=1;
q=1;
for (t=1; t<=wks.maxrows/201; t++)
{
for (i=r; i<=201; i++)
{
cell(q,t+2)=cell(i,2)
q=q+1;
}
r=i+1;
q=1;
}

For some reason this error only comes when I put q=q+1
Please help,
Thank You

cpyang

USA
1406 Posts

Posted - 08/05/2010 :  07:53:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
missing ; after cell(q,t+2)=cell(i,2)


CP
Go to Top of Page

thentangler

USA
Posts

Posted - 08/09/2010 :  12:33:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
Thank you so much... It worked. That was so silly of me.

But is there a way I can assign a range of rows from one column to another column instead of using a for loop?
Like if I want to assign the first 30 rows of col(A) to col(B)?
Thank You

Rudy
Go to Top of Page

larry_lan

China
Posts

Posted - 08/09/2010 :  09:50:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi:

You can specify the From and To rows in Set Column Value dialog. And you can also use Range in your script. For example


newbook;
wks.ncols = 4;
col(1) = data(1, 121);
range r1 = !col(1);
int nrow = 50;
for(ii = 2; ii <= 4; ii++)
{
	range r2 = r1[$((ii-2)*nrow+1):$((ii-1)*nrow)];
	wcol(ii) = r2;
}

Thanks
Larry
Go to Top of Page

thentangler

USA
Posts

Posted - 08/10/2010 :  12:18:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Larry,
Thank you for the script. But it still uses an elaborate for loop.
Is there a way like we do in MATLAB where we use B=A(1:30)
Where Matrix A is has more than 30 rows?

Thank You

Edited by - thentangler on 08/10/2010 12:20:03 AM
Go to Top of Page

larry_lan

China
Posts

Posted - 08/10/2010 :  06:35:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It's not a loop issue. In Origin, you'd better use range variables to specify sub-range of dataset:

range rr = col(a)[1:30];
col(b)=rr;


Thanks
Larry
Go to Top of Page

thentangler

USA
Posts

Posted - 08/15/2010 :  12:02:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Oh cool
Thats exactly what I was looking for.
Thanks a million.
:)
Go to Top of Page

DataConv

Germany
60 Posts

Posted - 08/16/2010 :  05:17:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There is also another way to handle this:
Convert your row of the worksheet in a numeric matrix, redimension it and convert it back (if needed) to a worksheet. Just 3 lines of code in the script...

Edited by - DataConv on 08/16/2010 05:19:37 AM
Go to Top of Page

thentangler

USA
Posts

Posted - 09/12/2010 :  10:52:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
When I try range rr= col(1)[1:30];
I cant seem to put variables in.
For example I cant store 1 in a and 30 in b and use the syntax:
range rr= col(1)[a:b]
It is just giving me the whole range of col(1)
What identifier should I use please?

Edited by - thentangler on 09/13/2010 02:14:54 AM
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 09/13/2010 :  07:51:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
for now, you have to use substitution notation

rr= col(1)[$(a):$(b)];


CP
Go to Top of Page

thentangler

USA
Posts

Posted - 11/07/2010 :  8:09:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank You so much.
That did the trick.
Thanks
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