Author |
Topic  |
|
eno
Japan
34 Posts |
Posted - 06/30/2003 : 02:08:34 AM
|
Hi,
Are there any commands to add rows or columns to arbitrary point of dataset? Here is an example.
index, col(A), col(B) 1, 0.0, 10.2 2, 0.5, 10.8 3, 1.0, 11.3 4, 2.0, 12.5 5, 2.5, 11.8
There is a missing data between index 3 and index 4. I would like to interpolate it.
index, col(A), col(B) 1, 0.0, 10.2 2, 0.5, 10.8 3, 1.0, 11.3 4, 1.5, (11.3+12.5)/2 5, 2.0, 12.5 6, 2.5, 11.8
The following is my incomplete script for the interpolation.
get data1 -e rownum; //get the number of rows int=0.5 //regular interval of col(A) loop(num,1,rownum-1) { rowp=%(data1,1,num); rowq=%(data1,1,num+1); rowr=%(data1,2,num); rows=%(data1,2,num+1); if(rowq-rowp!=int) { interp=(rowr+rows)/2; //interpolating data ??? ; //Adding a row to index num+1 %(data1,1,num+1)=rowp+int; //interpolating col(A) %(data1,2,num+1)=interp; //interpolating col(B) type"Missing data at row $(num+1) is interpolated."; }; };
I want to insert "Adding row" command to ???.
Thanks, eno
Edited by - eno on 06/30/2003 02:15:49 AM |
|
Mike Buess
USA
3037 Posts |
Posted - 06/30/2003 : 08:36:10 AM
|
Hi eno,
If you have Origin 7 you can write a simple Origin C function that uses Worksheet::InsertRow...
void NewRow(string wksName, int nrow) { Worksheet wks(wksName); wks.InsertRow(nrow); }
#Add a row at index num+1... NewRow "data1" num; // OC indices are 0-based
If you don't have Origin 7 you can use "menu -e menuID" to execute the Edit->Insert command. To find the menuID for that command open the script window and press the Ctrl and Shift keys while you select the command. It's menuID will show up in the script window.
#Add a row at index num+1... win -a data1; wo -s 0 (num+1) 0 (num+1); // select the row menu -e 36441; // menuID=36441 in Origin 7
...You also asked about inserting columns. Origin C has Worksheet::InsertCol that's similar to InsertRow. In LabTalk you can use
wo -i n colName;
to insert a column named colName at the n+1 position in the active wks.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 06/30/2003 08:48:32 AM
Edited by - Mike Buess on 06/30/2003 08:50:23 AM
Edited by - Mike Buess on 06/30/2003 10:54:47 AM
Edited by - Mike Buess on 06/30/2003 10:56:15 AM |
 |
|
|
Topic  |
|
|
|