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
 All Forums
 Origin Forum
 Origin Forum
 adjust columns

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
ungat Posted - 11/08/2005 : 08:58:37 AM
Origin Version (Select Help-->About Origin): 7.5
Operating System:Win XP

Hello everybody,

I have a problem with adjust columns when I import data:

I have to import 3 data with 2 columns (x,y) each other in one datasheet(x,y1,y2,y3), the 3 data have the same column x but not the same column y; one column y begin at x=a, one at x=b and the other at x=c but I want they begin each other at x=a=2,375 and fill by zero the empty cells in other y columns:

eaxample:
y1 y2 y3
2,375=a 0 0 3,96694E-6
2,425 0 0 2,07178E-4
2,475 0 0 0,00364
2,525 0 0 0,02779
2,575 0 0 0,11693
2,625 0 0 0,32308
2,675 0 0 0,66072
2,725=b 7,77778E-6 0 1,09083
2,775 6,33333E-5 0 1,55105
2,825 5,31111E-4 0 1,98904
2,875 0,00273 0 2,37846
2,925 0,01016 0 2,71199
2,975 0,029 0 2,99516
3,025 0,0658 0 3,23987
3,075 0,12723 0 3,4571
3,125 0,21817 0 3,65574
3,175 0,3379 0 3,84354
3,225 0,48842 0 4,02623
3,275 0,66422 0 4,20811
3,325 0,86412 0 4,39238
3,375 1,08686 0 4,58125
3,425=c 1,33101 1,04938E-5 4,77575
3,475 1,5992 4,19753E-5 4,9776
3,525 1,89598 1,28025E-4 5,18755

I hope you have understood and you'll help me

thank you very much.

30   L A T E S T    R E P L I E S    (Newest First)
ungat Posted - 11/17/2005 : 11:42:42 AM
Hello Mike Buess, excuse me for disturbing you again,

1°) is it possible to make several Custom Routine buttons ? I have made a Custom Routine button for one script; but what can I do for other scripts ? because I have several script window which I have to use more than once.

2°) I think script window page length is limited, because I can't continue.

3°) is it possible that a script submit an other script after its execution ?

I would like execute a script A which will submit a script B after its execution; the 2 script are located in the same directory.

Thank you very much.
Mike Buess Posted - 11/16/2005 : 07:13:07 AM
Use the set command. For example,

set Toto_tata -c 2; // color Toto_tata plot red

Help > Programming > LabTalk Language Reference > Command Reference > Alphabetical Listing > Set

Mike Buess
Origin WebRing Member
ungat Posted - 11/16/2005 : 05:28:02 AM
Hello, thank you very much,

I have another question, how do you indicate in script window Plot Details for Line:

- Connect ?

- Styl ?

- Line Width

- Line Color ?

for example for
win -t P; // create graph window
layer -i200 Toto_tata;

Thank you again.
Mike Buess Posted - 11/15/2005 : 4:53:27 PM
Graph must be active when you run this...

%Z="";
lay -c;
win -t D;
%A=%[%Z,#1];
copy xof(%A) %H_A;
copy %A %H_B;
nn=1;
loop (ii,2,count) {
%A=%[%A,#ii];
%H_B += %A;
nn++;
};
%H_B /= nn;

...And this fixes the script in my previous post...

%Z=AB CE MN;
win -t D;
%A=%[%Z,#1];
copy xof(%A_%A) %H_A;
copy %A_%A %H_B;
nn=1;
for(ii=2;ii>0;ii++) {
%A=%[%Z,#ii];
if(%A=="") break;
%H_B += %A_%A;
nn++;
};
%H_B /= nn;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/15/2005 5:05:46 PM

Edited by - Mike Buess on 11/15/2005 5:10:52 PM
ungat Posted - 11/15/2005 : 3:30:20 PM
[quote]
Change the command %R_B += %A_J to %R_B += %A_%A.

Excuse me I have an other solution to have the average,

how do you do to have Average Multiple Curves of a graph by using script window ?
ungat Posted - 11/15/2005 : 3:12:48 PM
[quote]
Change the command %R_B += %A_J to %R_B += %A_%A.

Excuse me it doesn't work, there is nothing in %R_B
Mike Buess Posted - 11/15/2005 : 2:22:33 PM
Change the command %R_B += %A_J to %R_B += %A_%A.

Mike Buess
Origin WebRing Member
ungat Posted - 11/15/2005 : 2:07:08 PM
[quote]
%Z=AB CE MN; // list wks names separated by spaces
%R=newData; // name for new wks
win -a %[%Z,#1]; // activate 1st wks
win -d; // duplicate
doc -e W {%W=%H};
win -r %W %R; // change its name
nn=1;
for(ii=2;ii>0;ii++) {
%A=%[%Z,#ii];
if(%A=="") break;
%R_B += %A_J;
nn++;
};
%R_B /= nn; // normalize by wks count
win -a %R; // activate new wks

Excuse me again;

in fact I want newData_B = (AB_AB + CE_CE +...+ ZX_ZX)/n

the columns which must be added have the same name that the corresponding whorksheets.

Thank you very much.
Mike Buess Posted - 11/15/2005 : 1:17:15 PM
%Z=AB CE MN; // list wks names separated by spaces
%R=newData; // name for new wks
win -a %[%Z,#1]; // activate 1st wks
win -d; // duplicate
doc -e W {%W=%H};
win -r %W %R; // change its name
nn=1;
for(ii=2;ii>0;ii++) {
%A=%[%Z,#ii];
if(%A=="") break;
%R_B += %A_J;
nn++;
};
%R_B /= nn; // normalize by wks count
win -a %R; // activate new wks


This will minimize all worksheets and arrange icons...

doc -e W {win -i};
menu -e 57649;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/15/2005 1:18:25 PM
ungat Posted - 11/15/2005 : 12:56:44 PM
Excuse me, in fact, my worksheets don't called Data1,Data2,...,Data10
it's AB, CE, MN,... it is not regular names;

I would like to create a newData with 2 columns: A(X) and B(Y)

with newData_A = AB_A = CE_A ...
newData_B = (AB_J + CE_J +...+ ZX_J)/n

By Reduce worksheets I mean lower worksheets size to minimum (icon) and arrange icons.

Thank you.
Mike Buess Posted - 11/15/2005 : 10:19:17 AM
1)
win -a Data1; // activate Data1
win -d; // duplicate
doc -e W {%W=%H};
win -r %W Moy; // change name to Moy
loop (ii,2,10) {Moy_B += Data$(ii)_B};
Moy_B /= 10;
win -a Moy;

2) Same as worksheet: win -r %H newName.

quote:
how do you reduce all worksheets in Origin Project with a script window ?

Assuming "reduce" means to add col B from all worksheets as in 1)...

%A=%H;
win -d;
doc -e W {%W=%H};
win -r %W Moy;
nn=1;
doc -e W {
if(%H!="Moy" && "%A!="%H") {
Moy_B += %H_B;
n++;
};
};
Moy_B /= nn;
win -a Moy;

Mike Buess
Origin WebRing Member
ungat Posted - 11/15/2005 : 08:34:23 AM
Excuse me, I have forgotten to ask you how do you reduce all worksheets in Origin Project with a script window ?

Thank you.
ungat Posted - 11/15/2005 : 08:31:48 AM
Hello,

1°) I have 10 worksheets Data1, Data2,...,Data10
and I would like to create a newData called "Moy" which will obtained so:

Moy_A(X) = Data1_A = Data2_A =...= Data10_A

Moy_B(Y) = (Data1_B + Data2_B +...+ Data10_B)/10

2°) How do you rename a graph ?

Thank you again.
Mike Buess Posted - 11/14/2005 : 5:23:07 PM
layer -g;

Mike Buess
Origin WebRing Member
ungat Posted - 11/14/2005 : 5:01:37 PM
Excuse me again,

it's ok, but how do you group data in Layer Contents ?
ungat Posted - 11/14/2005 : 4:50:39 PM
Ok thank you very much!
Mike Buess Posted - 11/14/2005 : 4:38:53 PM
The general syntax for plotting a dataset in the active graph layer is layer -i# dataset, where # is the graph type number (200=line, 201=scatter, etc.) and dataset is %(wksName,colNumber) or wksName_colName...

win -t P; // create graph window
layer -i200 Data1_B; // plot Data1, col B as line
layer -i200 Data2_C; // plot Data2, col C
layer -i200 DataN_Z; // plot DataN, col Z

Mike Buess
Origin WebRing Member
ungat Posted - 11/14/2005 : 4:23:03 PM
Ok, thank you very much Mike Buess;

but I don't want plot the 3 imported files; I would plot columns of other worksheets which were obtained from the 3 imported files.
In general case, how do you plot in the same graph column B of Data1, column C of Data2,..., column Z of DataN ?
Mike Buess Posted - 11/14/2005 : 1:10:47 PM
worksheet -s c1 r1 c2 r2 selects the range of cells in the worksheet beginning with col c1, row r1 and ending with col c2, row r2. r1 = 0 and r2 = 0 means select entire columns. Similarly, wo -s 0 0 0 0 selects the entire worksheet.

Plotting all imported data in the same graph window requires a different approach...

%B=D:\Directory\; // directory
%F=AA BB CC; // file list (space separated)
win -t P; // create a graph window
%P=%H; // save its name as %P
for(ii=1;ii>0;ii++) {
%A=%[%F,#ii]; // get next file name
if(%A=="") break;
win -t D;
open -w %B%A;
win -r %H %A; // rename wks window to file name (%A)
wks.col1.name$=Column 1 name; // supply your own names
wks.col2.name$=Column 2 name;
wks.col3.name$=Column 3 name;
// more columns?
wks.col1.label$=Column 1 label; // supply your own labels
wks.col2.label$=Column 2 label;
wks.col3.label$=Column 3 label;
// more columns?
wks.labels(); // show column labels
%W=%H; // save wks name as %W
win -a %P; // activate graph window
layer -i200 %(%W,3); // plot %W col 3 as line (201=scatter, 202=line+symbol)
};
layer -a; // rescale to show all data
legend; // recreate legend

Mike Buess
Origin WebRing Member
ungat Posted - 11/14/2005 : 12:49:58 PM
ok, excuse me for disturbing you;

how do you plot in the same graph Column C of Data1, column C of data2 and Column C of Data3 ?

what does it mean "wo -s 3 0 3 0" ? what is 0 for ?
Mike Buess Posted - 11/14/2005 : 12:41:34 PM
Add these lines after wks.labels()...

wo -s 3 0 3 0; // select column 3
wo -p 200; // plot as line (201=scatter, 202=line+symbol, etc)

Mike Buess
Origin WebRing Member
ungat Posted - 11/14/2005 : 12:31:47 PM
Ok, thank you very much;

how do you plot the column C of a wks ?

I have a worksheet named Data1 with 10 columns: A(X),B(Y),C(Y),....
and I would like to plot column C with script window you given me.

Thank you again.
Mike Buess Posted - 11/14/2005 : 11:34:10 AM
It's unclear to me whether you want to name the worksheets with the file name or change the names to something else. Following script renames the wks window after the file name and names and labels 3 columns. If you want to change the wks name to something else use win -r %H newName in place of the win -r %H %A command. Note that all of this is much more easily handled by using a custom worksheet template with the proper ASCII Options.

%B=D:\Directory\; // directory
%F=AA BB CC; // file list (space separated)
for(ii=1;ii>0;ii++) {
%A=%[%F,#ii]; // get next file name
if(%A=="") break;
win -t D;
open -w %B%A;
win -r %H %A; // rename wks window to file name (%A)
wks.col1.name$=Column 1 name; // supply your own names
wks.col2.name$=Column 2 name;
wks.col3.name$=Column 3 name;
// more columns?
wks.col1.label$=Column 1 label; // supply your own labels
wks.col2.label$=Column 2 label;
wks.col3.label$=Column 3 label;
// more columns?
wks.labels(); // show column labels
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/14/2005 12:02:27 PM
ungat Posted - 11/14/2005 : 11:12:24 AM
Excuse me Mike Buess, it's me again;

how do you rename files you imported with this script:

%B=D:\Directory\; // directory
%F=AA BB CC; // file list (space separated)
for(ii=1;ii>0;ii++) {
%A=%[%F,#ii]; // get next file name
if(%A=="") break;
win -t D;
open -w %B%A;
};


I would rename AA,BB and CC and their columns after importation

Thank you.
ungat Posted - 11/13/2005 : 3:53:41 PM
Excuse me I said it is the last question, but I have another one;

how do you import 3 or more data files at one time ?
Now for import 3 data I use this sript window:
--------------------------------------------------------------------
run.section(Standard,NewWks);
getfile *.*;
open -w %b%a;
%v=%h;
ncols=%v!wks.ncols;
%v!wks.col1.name$=Abs;
for(i=1;i<=ncols-1;i+=1)
{
create %v_b$(i) 300;
edit %v_b$(i);
copy col($(i+1)) %v_b$(i);
};
copy col(1) %v_a;
for(i=1;i<=ncols;i+=1)
{
delete col(1);
};
run.section(Standard,NewWks);
getfile *.*;
open -w %b%a;
%v=%h;
ncols=%v!wks.ncols;
%v!wks.col1.name$=Abs;
for(i=1;i<=ncols-1;i+=1)
{
create %v_b$(i) 300;
edit %v_b$(i);
copy col($(i+1)) %v_b$(i);
};
copy col(1) %v_a;
for(i=1;i<=ncols;i+=1)
{
delete col(1);
};
run.section(Standard,NewWks);
getfile *.*;
open -w %b%a;
%v=%h;
ncols=%v!wks.ncols;
%v!wks.col1.name$=Abs;
for(i=1;i<=ncols-1;i+=1)
{
create %v_b$(i) 300;
edit %v_b$(i);
copy col($(i+1)) %v_b$(i);
};
copy col(1) %v_a;
for(i=1;i<=ncols;i+=1)
{
delete col(1);
};
--------------------------------------------------------------------

But it takes more time to import one per one; I would like to select the 3 files and import them at one time.

Thank you very much.
Mike Buess Posted - 11/13/2005 : 3:09:09 PM
This changes the label for column i to newLabel...

wks.col$(i).label$=newLabel;

Mike Buess
Origin WebRing Member
ungat Posted - 11/13/2005 : 3:03:22 PM
Ok thank you very much, I have a last question: how do you rename Column Label ?

quote:

Hi,

I suspect that you need to apply the SR5 patch to get rid of the compiler error...
http://www.originlab.com/index.aspx?s=9&lm=76

This will rename the active window to newName...
win -r %H newName;

Either of the following commands will rename column i to newName...
wo -n i newName;
wks.col$(i).name$=newName;

Mike Buess
Origin WebRing Member

Mike Buess Posted - 11/13/2005 : 2:47:16 PM
Hi,

I suspect that you need to apply the SR5 patch to get rid of the compiler error...
http://www.originlab.com/index.aspx?s=9&lm=76

This will rename the active window to newName...
win -r %H newName;

Either of the following commands will rename column i to newName...
wo -n i newName;
wks.col$(i).name$=newName;

Mike Buess
Origin WebRing Member
ungat Posted - 11/13/2005 : 2:29:26 PM

[/quote]

Hello, excuse me for disturbing you again, but there is an error in compiling the file; the error message is folloving:

compiling...
essai1.c
D:\Origin\essai1.c(53) :Error, Member function Worksheet::SetSize not defined or does not have matching prototype.
D:\Origin\essai1.c(26) :Error, error(s) found in compiling method
D:\Origin\essai1.c(53) :Error, general compile error
D:\Origin\essai1.c(26) :Error, error(s) found in compiling function wks_combine

Compiling errors found, linking cannot start!

the file is folloving:

/*------------------------------------------------------------------------------*
* File Name:essai1 *
* Creation: 13.11.2005 *
* Purpose: OriginC Source C file *
* Copyright (c) ABCD Corp. 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 *
* All Rights Reserved *
* *
* Modification Log: *
*------------------------------------------------------------------------------*/

////////////////////////////////////////////////////////////////////////////////////
// Including the system header file Origin.h should be sufficient for most Origin
// applications and is recommended. Origin.h includes many of the most common system
// header files and is automatically pre-compiled when Origin runs the first time.
// Programs including Origin.h subsequently compile much more quickly as long as
// the size and number of other included header files is minimized. All NAG header
// files are now included in Origin.h and no longer need be separately included.
//
// Right-click on the line below and select 'Open "Origin.h"' to open the Origin.h
// system header file.
#include <Origin.h>
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
// Start your functions here.
// Origin C functions start here
void wks_combine(string sList)
{
StringArray sa;
sList.GetTokens(sa,',');
if( sa.GetSize()<2 )
return;
Dataset dx,tmp;
Worksheet wks;
double dInc;
for(int i=0; i<sa.GetSize(); i++)
{
wks.Attach(sa[i]);
if( !wks ) return;
dx.Attach(wks,0);
if( i )
tmp.Append(dx);
else
{
dInc = dx[1] - dx[0];
tmp.Create(dx.GetSize());
tmp = dx;
}
}
Worksheet wksNew;
wksNew.Create("Origin");
dx.Attach(wksNew,0);
dx.Data(min(tmp), max(tmp), dInc);
wksNew.SetSize(dx.GetSize(), sa.GetSize() + 1);
for(i=1; i<=sa.GetSize(); i++)
{
if( wks_copy(wksNew,i,sa[i-1]) )
break;
}
}
int wks_copy(Worksheet wDest, int iCol, string sSrc)
{
Dataset dxSrc(sSrc,0);
Dataset dySrc(sSrc,1);
if( !dxSrc || !dySrc )
return 1;
Dataset dxDest(wDest,0);
Dataset dyDest(wDest,iCol);
dyDest.SetSize(dxDest.GetSize());
dyDest = 0;
Data_copy(&dyDest,&dySrc,0,dySrc.GetSize() - 1,Data_list(dxSrc[0],&dxDest));
return 0;
}

==================================================================

I have an other problem, how do you rename an imported worksheet and how do you rename the columns of this worksheet ? I would like rename the worksheet and its columns with a window script.

Thank you again.
ungat Posted - 11/10/2005 : 1:20:13 PM
Ok thank you very much Mike Buess

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000