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 for Programming
 LabTalk Forum
 incomplete help

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
couturier Posted - 01/10/2008 : 08:46:42 AM
Origin Version (Select Help-->About Origin): 8 ProSR1
Operating System: XP pro

In the col function labtalk help, I see:
The col(colNameOrNum)[colHdrType]$ function accesses the column headers (e.g., Long Name, Units, Comment, Parameters, Sampling Interval and user-defined headers), and it has similar syntax to Col(colNameOrNum)[rowNum]$ .

Example:
col(2)[L]$=my full name; // set long name
%a=col(2)[U]$; // get units
%a=col(2)[D2]$; // get the 2nd user defined header

No hints on how to adress other parameters (comments, sampling rate)

10   L A T E S T    R E P L I E S    (Newest First)
OndrejMM Posted - 06/19/2009 : 7:06:25 PM
hi easwar, thank you very much for the careful explanation and sorry i didn't get your advice at first,... here is the working script if someone needs it,... cheers, ondrej

// at the beginning we have only one sheet with data which we
// want to fit in the following format YX1X2X3X4....Xn
//////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// create result worksheet and declare ranges, this is going to be
// the second sheet in the current workbook
newsheet name:=results c:=5 labels:="reflection|slope|slope err|intercept|intercept err";
range reflection=1, slope=2, slopeerr=3, intercept=4, intercepterr=5;
// define columns short names
wks.col1.name$ = reflection;
wks.col2.name$ = slope;
wks.col3.name$ = slope.err;
wks.col4.name$ = intercept;
wks.col5.name$ = intercept.err;

// now switch back the data sheet
page.active=1;

string mybk$=%H;
range aa = 1!;//1st sheet, assume we start with just one data sheet
slopes.SetSize(aa.ncols-1); // number of Ys in our data wks
// start the fitting loop
loop(ii,2,aa.ncols) {
range dd = 1!(wcol(ii), 1);
newsheet name:=FitLine$(ii-1);
fitlr iy:=dd oy:=FitLine$(ii-1)!(1,2);
slope[ii-1] = fitlr.b;//ii-1 because we loop from 2
slopeerr[ii-1] = fitlr.berr;
intercept[ii-1] = fitlr.a;
intercepterr[ii-1] = fitlr.aerr;
};

// at this point all the fitting results are already
// in the "results" sheet (2!) except column names

// take the columns' names and put them into the
// "results" worksheet

page.active = 1;
nn=wks.ncols;
loop(ii,2,nn) {
reflection[ii-1]$=wks.col$(ii).name$; // put directly into range/col
}

// now plot with all the source data and fit and add a lable to show name and slope
loop(ii,2,aa.ncols) {
range data = [mybk$]1!(wcol(ii),1);
range fit = [mybk$]FitLine$(ii-1)!(1,2);
win -t plot;
plotxy data plot:=201 o:=<active>;//plot source data as scatter
plotxy fit plot:=200 rescal:=0 color:=color(red) o:=<active>;
label -r legend;// we dont really need a legend
label -s -q 2 -n myLabel1 "Linear Fit to %(1,@LM)
slope=$(slopes[ii-1])
slope.err=$(slopes_err[ii-1])
intercept=$(intercepts[ii-1])
intercept.err=$(intercepts_err[ii-1])";
}

// merge all graphs
merge_graph option:=open keep:=0 col:=3 aspectratio:=1;

// end



easwar Posted - 06/19/2009 : 3:37:08 PM
Hi,

In your code you are still using temp datasets, your variable reflections is a dataset, and temp datasets are created as numeric so when you put a string in there it just becomes missing value -- so later even if you copy to a column/range what you wanted is already lost.

What i meant is to not use temp datasets at all...so just make the result sheet first and declare ranges at the very beginning, so you could do this:


// Make result worksheet right away, at the begining, and declare ranges
newsheet name:=results c:=5 labels:="reflection|slope|slope err|intercept|intercept err";
range reflection=1, slope=2, slopeerr=3, intercept=4, intercepterr=5;
wks.col1.name$ = reflection;
wks.col2.name$ = slope;
wks.col3.name$ = slope.err;
wks.col4.name$ = intercept;
wks.col5.name$ = intercept.err;
// now switch back to your data sheet
page.active=1; // assuming your data is in sheet 1

// now do your computations
// and directly put your results into the range itself
// no need to put first into dataset
...
...
reflection[ii-1]$=wks.col$(ii).name$; // put directly into range/col
...
// later can mainpulate the range for numeric stuff
intercept +=100; // can do scaling, offset etc later as desired


In other words just drop out the datasets altogether and work with ranges which basically point to columns.

Easwar
OriginLab
OndrejMM Posted - 06/18/2009 : 7:15:19 PM
Hi, thanks a lot for your time, ... I've rewritten the script as you suggested using the range notation but still that one column in the results worksheet which supposes to contain the column names held in the dataset "reflections" is empty or actually not empty but contains "--" (double-dash),... everything else works great! whole script is below but I think I've already tried all combinations but still no luck,... cheers, ondrej

string mybk$=%H;
//newsheet name:=FitLines c:=1;// add new sheet to hold fit lines
range aa = 1!;//1st sheet, assume we start with just one data sheet
//range bb = FitLines!;// the newly added sheet called "FitLines"
//bb.ncols = aa.ncols;// Add new columns in FitLines sheet
// loop all cols and fit lr and put results into line
// the FitLR X-Function is used
dataset slopes, slopes_err, intercepts, intercepts_err, reflections; // to hold fitting result parameters
slopes.SetSize(aa.ncols-1); // number of Ys in our data wks
intercepts.SetSize(slopes.GetSize());// not needed for now, but may be want this later

loop(ii,2,aa.ncols) {
range dd = 1!(wcol(ii), 1);
newsheet name:=FitLine$(ii-1);
fitlr iy:=dd oy:=FitLine$(ii-1)!(1,2);
slopes[ii-1] = fitlr.b;//ii-1 because we loop from 2
slopes_err[ii-1] = fitlr.berr;
intercepts[ii-1] = fitlr.a;
intercepts_err[ii-1] = fitlr.aerr;
};

page.active = 1;
nn=wks.ncols;
loop(ii,2,nn) {
reflections[ii-1]$=wks.col$(ii).name$;
}



newsheet name:=results c:=5 labels:="reflection|slope|slope err|intercept|intercept err";
range reflection=1, slope=2, slopeerr=3, intercept=4, intercepterr=5;
wks.col1.name$ = reflection;
wks.col2.name$ = slope;
wks.col3.name$ = slope.err;
wks.col4.name$ = intercept;
wks.col5.name$ = intercept.err;

reflection = reflections;
slope = slopes*1000;
slopeerr= slopes_err*1000;
intercept= intercepts;
intercepterr= intercepts_err;


// now we can make a plot with all the source data and fit and add a lable to show name and slope
loop(ii,2,aa.ncols) {
range data = [mybk$]1!(wcol(ii),1);
range fit = [mybk$]FitLine$(ii-1)!(1,2);
win -t plot;
plotxy data plot:=201 o:=<active>;//plot source data as scatter
plotxy fit plot:=200 rescal:=0 color:=color(red) o:=<active>;
label -r legend;// we dont really need a legend
label -s -q 2 -n myLabel1 "Linear Fit to %(1,@LM)
slope=$(slopes[ii-1])
slope.err=$(slopes_err[ii-1])
intercept=$(intercepts[ii-1])
intercept.err=$(intercepts_err[ii-1])";
}

merge_graph option:=open keep:=0 col:=3 aspectratio:=1;
easwar Posted - 06/18/2009 : 08:58:14 AM
Hi,

I was incorrectly assuming that reflection was a range pointing to a column, did not realize you were defining it as a loose dataset.

Why not create the result worksheet in the beginning itself and declare ranges to point to the columns of the result worksheet, and then directly address them?

So you could do:
newsheet name:=results c:=5 labels:="reflection|slope|slope err|intercept|intercept err";
range reflection=1, slope=2, slopeerr=3, intercept=4, intercepterr=5;


and then
reflection[ii-1]$=wks.col$(ii).name$;
works fine.

Also for other quantities you can directly put the results into the range which would directly go into the result sheet columns.

Easwar
OriginLab
OndrejMM Posted - 06/17/2009 : 9:58:22 PM
Hi easwar,

yeah, it was coming definetely from that line,... now it runs without an error but it doesn't hold the column short names in the variable "reflection",.. or at least it looks like that,... maybe you see an additional error? many thanks, ondrej

dataset slopes, slopes_err, intercepts, intercepts_err, reflection; // to hold fitting result parameters

loop(ii,2,aa.ncols) {
range dd = 1!(wcol(ii), 1);
newsheet name:=FitLine$(ii-1);
fitlr iy:=dd oy:=FitLine$(ii-1)!(1,2);
slopes[ii-1] = fitlr.b;//ii-1 because we loop from 2
slopes_err[ii-1] = fitlr.berr;
intercepts[ii-1] = fitlr.a;
intercepts_err[ii-1] = fitlr.aerr;
};

page.active = 1;
nn=wks.ncols;
loop(ii,2,nn) {
reflection[ii-1]$=wks.col$(ii).name$;
}

newsheet name:=results c:=5; //create new worksheet
wks.col1.name$ = reflection;
wks.col2.name$ = slope;
wks.col3.name$ = slope.err;
wks.col4.name$ = intercept;
wks.col5.name$ = intercept.err;

col(1)=reflection;
col(2)=slopes*1000;
col(3)=slopes_err*1000;
col(4)=intercepts;
col(5)=intercepts_err;
easwar Posted - 06/17/2009 : 9:22:02 PM
Hi,

Must be this line:
reflection[ii-1]=%(wks.col$(ii).name$);
change to:
reflection[ii-1]$=wks.col$(ii).name$;

Easwar
OriginLab
OndrejMM Posted - 06/17/2009 : 6:53:50 PM
Hi Laurie,
thanks for that, I'm not trying to change the short name but i'm trying to read it and save in a "dataset",...

reflection[ii-1]=%(wks.col$(ii).name$);

see my script but there must be some problem with the notation, because I'm getting the following error:

Error: %Y:
LabTalk expression error: 31603

script:

dataset slopes, slopes_err, intercepts, intercepts_err, reflection; // to hold fitting result parameters
loop(ii,2,aa.ncols) {
range dd = 1!(wcol(ii), 1);
newsheet name:=FitLine$(ii-1);
fitlr iy:=dd oy:=FitLine$(ii-1)!(1,2);
reflection[ii-1]=%(wks.col$(ii).name$);
slopes[ii-1] = fitlr.b;//ii-1 because we loop from 2
slopes_err[ii-1] = fitlr.berr;
intercepts[ii-1] = fitlr.a;
intercepts_err[ii-1] = fitlr.aerr;
};

Laurie Posted - 06/17/2009 : 09:22:46 AM
wks.coln.name$ = ; //returns the column shortname of the nth column

The name property of a column can be used to read or write the value. However, best not to change the short name.

OriginLab Technical Support
OndrejMM Posted - 06/17/2009 : 07:53:52 AM
and how can i access column short name? I'm trying to find it in the help but no luck,... thanks, ondrej
cpyang Posted - 01/10/2008 : 7:34:38 PM
The online documentation is based on public wiki pages and we can check and see why some pages not included into the online help:

http://wiki.originlab.com/~originla/wiki/index.php?title=LabTalk:Column_Label_Row_Characters

The idea of using public wiki to edit our programming documentation is that we will welcome users to also help add to these documentations as more and more people get to know more of these new things and find problems in the lack of examples etc.

CP

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