| T O P I C R E V I E W |
| 0mega |
Posted - 05/23/2006 : 07:31:30 AM Hi, I'm very new to Origin and Labtalk and got stuck with a problem. I simply don't know where to start (yeah and my title is not very helpful :)). ... Okay. I got a script which imports data over ASCII txt Files and uses Templates for the several Graphs. One Graph is a Voltage - Luminosity (btw: for LEDs) Diagramm. I want a textbox which gives me "AA Volt @ 100cd BB Volt @ 1000cd" or: f(Voltage) = 100cd/1000cd = AA / BB
Now how can I do this? Is it possible to adjust the textbox of the template with a formula/function/... or do I have to include it in the script?
I hope you got my problem. Thanks for your help.
Edited by - 0mega on 05/30/2006 04:32:12 AM |
| 11 L A T E S T R E P L I E S (Newest First) |
| 0mega |
Posted - 05/31/2006 : 04:11:39 AM OK. The first Problem is solved.
I use: //Textbox (VOL @ 100/1000cd): %L="Quadrant $(i): $(AA)V @ 100cd/m2 \n$(BB)V @ 1000cd/m2"; label -s -sa -n MyLabel$(i) %L; MyLabel$(i).fsize=12; MyLabel$(i).x=5.6; MyLabel$(i).y=0.000000005*(10^$(i));
to create multiple texboxes and align them different at the log-axis. Good to know that it's so simple :)
Only the 2. Problem left for the moment. Any hint? :(
Edited by - 0mega on 06/01/2006 03:00:25 AM |
| 0mega |
Posted - 05/31/2006 : 02:02:06 AM At first - here is my Textbox and Interpolation (%W=%H):
win -a CD-VOL3; //Interpolation for textbox (VOL @ 100/1000cd) tempdataY={100,1000}; tempdataX=Table(%W_B, %W_VoltageV, tempdataY); AA=tempdataX[1]; BB=tempdataX[2]; delete tempdataY; //Clean up delete tempdataX;
//Textbox: %L="Quadrant$(i): $(AA) Volt @ 100cd/m2 and $(BB) Volt @ 1000cd/m2"; label -s -sa -n MyLabelA %L; // create label and name it MyLabelA MyLabelA.fsize=14; // set font size MyLabelA.x=-5; // center label at X=10 MyLabelA.y=0.0000001; // center label at Y=100
#1 I don't really get this :( As you see I got a textbox with the interpolated value. Now I want to add a value / create a new texbox for each loop.
#2 Above you see the interpolation table-function I'm using. The problem is that there are sometimes 2 X-Values for Y=100. And if the table function finds a second match this will overwrite the first. Soo .. I want that origin stops after finding the first value OR only reads the first 30 columns OR ignores the second one / overwrite that instead.
Hope you understand my problem.
Thanks! :) |
| larry_lan |
Posted - 05/30/2006 : 11:03:01 PM Hi Omega:
1. Most of labtalk functions are based on the actived worksheet, since you have imported multiple data, you should active the worksheet which you want to operate on, in your loop script. Assume that you import multiple files named data1, data2, ... , change the scripts like:
for(ii=1; ii<=fdlog.multiopen.count;ii++) { win -a data$(ii); ...... ( write your script here ) }
2. I didn't quite understand that, because interpolation generates only one value, but anyway, if you want to search the first 30 column, maybe you can use break command to terminate the searching. Suppose there are two columns, Data1_A is x column and Data1_2 is y column:
xx=0; for(ii=1; ii<=30; ii++) { if(Data1_B[$(ii)] == somevalue) { xx=Data1_A[$(ii)]; break; } }
Is this what you need?
Larry OriginLab GZ Office |
| 0mega |
Posted - 05/30/2006 : 04:30:22 AM Thanks for your answer! It works really fine. I use "table" now. Only two things:
#1 I use for(i=1;i<=fdlog.multiopen.count;i+=1) {
to open multiple Data so that I have 4 graphs in 1 diagramm at the end. The interpolation only works for 1 graph. I could make 4 textboxes - but can I get them into one. (Like this: "Graph1: X Volt @ 100cd Y Volt @ 1000cd Graph2: Z Volt @ 100cd ...")
#2 Some graphs have 2 X-Values where Y is 100/1000. Can I tell origin to use the first Value he finds OR to search only in the first 30 rows (and ignore the last wrong values).
That's it :)
Thanks for your patience ;)
Edited by - 0mega on 05/30/2006 04:31:15 AM |
| Laurie |
Posted - 05/24/2006 : 11:12:18 AM Hi Omega,
When using the copy command, you need to specify the complete dataset name which is WorksheetName_ColumnName. You could use %H in place of WorksheetName if the worksheet is the active window, as %H is a system string variable that returns the name of the active window.
So for example, you could use: copy %H_B test_A; copy %H_VoltageV test;
However as Larry stated you can just do a direct assignment; no need for the copy command, just say:
col(4)=col(2);
Note: The col function takes either a column name or column index as an argument.
Regarding interpolation, Variable=WksName_ColName(Xvalue); or Variable=col(5)(1000); is fine. The first is explicit whereas you could run the second one on any worksheet that had at least 5 columns. You may have noticed though that if you type the following in the Script Window:
col(5)(1000)=;
It will return a missing value. COL(5)(1000)=--
Whereas the following:
data1_B(1000)=; //will not return missing value
But this is just a difference when returning the value to the Script Window.
I have another slightly different way you can interpolate. You can use the table function. This function takes three dataset names as arguments. If you wish to return Y values, then the order in which you pass the datasets is X,Y,X and if you had wished to return X values then you'd use Y,X,Y. The first two datasets are the datasets that you are interpolating and the last dataset holds the values that you want to find an interpolated value for.
Also you don't need to use the create command to create a temporary dataset. You can create it as needed. Here's an example:
tempdataY={100,1000}; tempdataX=Table(%H_B, %H_VoltageV, tempdataY); AA=tempdataX[1]; BB=tempdataX[2]; delete tempdataY; //clean up delete tempdataX; //delete temp datasets
Laurie
OriginLab Technical Support |
| 0mega |
Posted - 05/24/2006 : 06:12:35 AM Hm ...
maybe like this?
create test -c 65 //create 2 new columns for 65 values and call them test and test_A (correspoding X dataset) ..? copy B test_A copy VoltageV test M = col(5)(1000);
// B = Name of column 2 [Y] // VoltageV = Name of column 1 [X] The copy dataset1 dataset2 command ... "dataset1" means the name of the dataset not the labelling right? I'm a little bit confused ;)
BTW: If I ask too dumb questions please tell me where to find a good tutorial ;)
[Edit]: About interpolating ... "Variable=WksName_ColName(Xvalue);" - isn't this better? Or is "M = col(5)(1000);" enough. thx
Edited by - 0mega on 05/24/2006 06:16:19 AM |
| larry_lan |
Posted - 05/24/2006 : 05:04:38 AM Hi Omega:
There is only one letter in the global string variable, so %BC is illegal , unless you have define %B.
You can get the interpolated points by yDataset(interpolatedXValue) function, but noticed that this function accepts a x value and interpolate a y value. Suppose want to get a x value of column 1 at 1000, y value, of column 2, two more columns, col(4) and col(5) are need, and set col(4)=col(2) as x value, col(5)=col(1) as y value. Then can get the result of BB in your scripts directly by:
BB = col(5)(1000);
Larry OriginLab GZ Office
Edited by - larry_lan on 05/24/2006 05:41:52 AM |
| 0mega |
Posted - 05/24/2006 : 03:46:28 AM Hm. Doesn't work :(
The textbox always gives me "Current Density (mA/cm²)" - but that's the title of Column 3!!!
Here is the original code: win -a CD-VOL3; layer -s 2; //Select layer 2 layer -i %(%W,2); //Include second dataset(column) in the active layer layer -g; //Group Datasets layer -s 1; layer -i %(%W,3); layer -g; XXX win -h 1;
And at XXX I insert: %BC=xof(col(1)); BB=%BC[list(1000, col(1))]; %L="%(BB) Volt @ 1000cd/m\+(2)"; label -s -sa -n MyLabelA %L; // create label and name it MyLabelA MyLabelA.fsize=18; // set font size MyLabelA.x=-5.3; // center label at X=10 MyLabelA.y=0.0000001; // center label at Y=100
BTW: In column 2 (where the y-values are) there is no exact 100 or 1000 [because of measured values] - don't know if you need to interpolate it ...
Here some additional information about the worksheet: Column 1 - Voltage - X-Value Column 2 - Luminance - Y-Value(left) Column 3 - Density - Y-Value(right)
Edited by - 0mega on 05/24/2006 03:50:37 AM |
| Deanna |
Posted - 05/24/2006 : 03:08:25 AM Probably you can do it like this:
Suppose the Y values are stored in Column(4). Then you may find out the corresponding X value (bb) for Y=1000 by
%a=xof(col(4)); bb=%a[list(1000, col(4))];
Deanna OriginLab GZ Office
Edited by - Deanna on 05/24/2006 03:09:15 AM |
| 0mega |
Posted - 05/24/2006 : 01:49:40 AM Thanks for your answer. The Idea is good.
Now the only thing is to calculate AA and BB.
f(AA)=100cd f(bb)=1000cd
So I "only" need the X-Value at 100cd and 1000cd (which is the Y-axis). How can I do this? |
| Mike Buess |
Posted - 05/23/2006 : 10:20:35 AM Probably better to create the label by script. This assumes the variables AA and BB are already defined...
%Z="$(AA) Volt @ 100cd\n$(BB) Volt @ 1000cd\nf(Voltage) = 100cd/1000cd = $(AA/BB)"; label -s -sa -n MyLabel %Z; // create label and name it MyLabel MyLabel.fsize=20; // set font size MyLabel.x=10; // center label at X=10 MyLabel.y=100; // center label at Y=100
Mike Buess Origin WebRing Member |