Author |
Topic |
|
j.miao
Germany
4 Posts |
Posted - 07/24/2014 : 09:10:22 AM
|
Hello everyone,
I have a data with two columns, i.e. column (1), column (2).
I want to separate the columns, meaning that Origin is supposed to copy the first 150 data points from columns (1, 2) to columns (3, 4), and the second 150 data points from columns (1, 2) to columns (5, 6), and so on
However, I have 1500 rows, or 10 columns with 150 data points each, so writing a script like that will take considerable time. (or even more rows)
So my question is: How can I write a kind of loop for that function which would also make it easy to change the number of points?
I use OriginPro 8.5.1.
Thanks in advance for any help! 07/24/2014
JUN |
|
lkb0221
China
497 Posts |
Posted - 07/24/2014 : 10:54:34 AM
|
Hi,
The following script will only copy numeric data over. // range r1 = 1; // Col(1) range r2 = 2; // Col(2) int Num = (wks.nrows / 150) + 1; // +1 for extra data for (int ii = 1; ii <= Num; ii++) { range d1 = $(2*ii+1); range d2 = $(2*ii+2); copydata irng:=r1[$(ii*150-149):$(ii*150)] orng:=d1; copydata irng:=r2[$(ii*150-149):$(ii*150)] orng:=d2; } //
Zheng OriginLab |
Edited by - lkb0221 on 07/24/2014 10:56:12 AM |
|
|
j.miao
Germany
4 Posts |
Posted - 07/24/2014 : 11:19:32 AM
|
Thanks a lots for your help. It works well and make a good shape.
However, the columns cannot be set to be X and Y, respectively. meaning, col(3)-X ; col(4)-Y; col(5)-X ; col(6)-Y; col(7)-X ; col(8)-Y; and so on.
Could you give a suggestion or improve that script?
Thanks again!
quote: Originally posted by lkb0221
Hi,
The following script will only copy numeric data over. // range r1 = 1; // Col(1) range r2 = 2; // Col(2) int Num = (wks.nrows / 150) + 1; // +1 for extra data for (int ii = 1; ii <= Num; ii++) { range d1 = $(2*ii+1); range d2 = $(2*ii+2); copydata irng:=r1[$(ii*150-149):$(ii*150)] orng:=d1; copydata irng:=r2[$(ii*150-149):$(ii*150)] orng:=d2; } //
Zheng OriginLab
JUN |
|
|
j.miao
Germany
4 Posts |
Posted - 07/24/2014 : 11:28:23 AM
|
Moreover,
If the interval was 200 (or 250) instead of 150, how could I do with that?
Thanks again!
quote: Originally posted by lkb0221
Hi,
The following script will only copy numeric data over. // range r1 = 1; // Col(1) range r2 = 2; // Col(2) int Num = (wks.nrows / 150) + 1; // +1 for extra data for (int ii = 1; ii <= Num; ii++) { range d1 = $(2*ii+1); range d2 = $(2*ii+2); copydata irng:=r1[$(ii*150-149):$(ii*150)] orng:=d1; copydata irng:=r2[$(ii*150-149):$(ii*150)] orng:=d2; } //
Zheng OriginLab
JUN |
Edited by - j.miao on 07/24/2014 11:29:34 AM |
|
|
lkb0221
China
497 Posts |
Posted - 07/24/2014 : 11:42:16 AM
|
Hi,
Please try the following script, change the variable WinSize (3rd line) for different intervals
// Start range r1 = 1; // Col(1) range r2 = 2; // Col(2) int WinSize = 150; // Window size int Num = (wks.nrows / WinSize) + 1; // +1 for extra data in case for (int ii = 1; ii <= Num; ii++) { range d1 = $(2*ii+1); range d2 = $(2*ii+2); copydata irng:=r1[$((ii - 1) * WinSize + 1):$(ii * WinSize)] orng:=d1; copydata irng:=r2[$((ii - 1) * WinSize + 1):$(ii * WinSize)] orng:=d2; wks.col$(2*ii+1).type = 4; // Set column be X wks.col$(2*ii+2).type = 1; // Set column be Y } // End
Zheng OriginLab |
|
|
j.miao
Germany
4 Posts |
Posted - 07/24/2014 : 12:13:18 PM
|
Great!
That is what I want!
Thanks a lot!
quote: Originally posted by lkb0221
Hi,
Please try the following script, change the variable WinSize (3rd line) for different intervals
// Start range r1 = 1; // Col(1) range r2 = 2; // Col(2) int WinSize = 150; // Window size int Num = (wks.nrows / WinSize) + 1; // +1 for extra data in case for (int ii = 1; ii <= Num; ii++) { range d1 = $(2*ii+1); range d2 = $(2*ii+2); copydata irng:=r1[$((ii - 1) * WinSize + 1):$(ii * WinSize)] orng:=d1; copydata irng:=r2[$((ii - 1) * WinSize + 1):$(ii * WinSize)] orng:=d2; wks.col$(2*ii+1).type = 4; // Set column be X wks.col$(2*ii+2).type = 1; // Set column be Y } // End
Zheng OriginLab
JUN |
|
|
|
Topic |
|
|
|