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
 Merging two columns into one column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

karvek

13 Posts

Posted - 10/17/2019 :  11:33:37 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I think I am trying to do something really stupid but I cannot manage somehow.

I have two columns and I want to create a third column formed by certain specific ranges of the previous columns.

If I put
range r1 = A[1:10]
range r2 = B[11:20]
as before formula script I can assign the range values using r1 or r2 but I don't understand which operation should I use to append r2 to r1.

Writing r1+r2 makes the sum, but I actually want a simple column formed by two different column ranges...

Anyone has a suggestion on how to do it?
Thanks

Origin Ver.2018b
Operating System:Windows10

yuki_wu

896 Posts

Posted - 10/17/2019 :  10:21:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can use copy command:
range r1 = A[1:10];
range r2 = B[11:20];
range r3 = C;
r3 = r1;
copy -a r2 r3;

Copy Command: https://www.originlab.com/doc/LabTalk/ref/Copy-cmd#-a.3BAppend_contents_of_dataset1_to_the_end_of_dataset2.

Regards, Yuki
OriginLab
Go to Top of Page

karvek

13 Posts

Posted - 10/18/2019 :  08:32:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Yuki,

that works beautiful.

Now assume I would like to create a column that is formed by a certain range (like r1) and another range that is a single value of colB repeated a fixed number of times.

I am trying to use
r2 = cell(11,2);
range r3 = C;
for (i=1; i<10; i++)
{copy -a r2 r3;};

but it does not really work.
Looking forward for your suggestion!

EDIT: I solved it using the repeat function, the problem is the way Origin is handling the "empty" (NAN) cells and this conflicts with range. I was unable to find a command to fully delete this NAN values so I had to do this manually, but now it works.

Edited by - karvek on 10/18/2019 09:22:38 AM
Go to Top of Page

yuki_wu

896 Posts

Posted - 10/22/2019 :  03:35:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can call X-Function wreducerows to reduce missing value:
https://www.originlab.com/doc/X-Function/ref/wreducerows

Regards, Yuki

OriginLab
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