Author |
Topic  |
|
dean.pask
UK
Posts |
Posted - 10/14/2005 : 11:13:12 AM
|
Origin Version (Select Help-->About Origin): 7.5 Pro Operating System: XP
Hi,
Please can anyone advise how to take a value from a worksheet (ie column B row 3) and display this onto a graph in a position defined by the user.
Have a great weekend all.
Dean |
|
Mike Buess
USA
3037 Posts |
Posted - 10/15/2005 : 11:28:08 AM
|
Hi Dean,
Use the label command to create a text label with the message you want. Each text label is given a unique name like Text, Text1, Text2, etc. and you can move the center of the label to a given set of graph coordinates using the standard object properties labelName.x and labelName.y. The following script creates a text label containing the cell value in row 3, column 2 of Data1. It then finds the name of the label and positions it at coordinates xx and yy. I assume that this is in reference to your peak labelling question in another topic, in which case xx is the peak position and yy is the peak height. Since you will want the text label to appear above the peak I've raised its center position from yy to yy + labelHeight, or yy + labelName.dy.
%W=Data1; // wks name label -s $(%W!cell(3,2)); // create text label doc -e G { // find its name - will be the first match encountered if("%[%B,5]"=="text") break; }; %B.x = xx; // move center of label to X = xx %B.y = yy + %B.dy; // move center to Y = yy + labelHeight
LabTalk Language Reference > Command Reference > Alphabetical Listing > Document and Label
LabTalk Language Reference > Object Reference > Internal Object Overview > User-created Visual Objects
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/15/2005 11:34:11 AM |
 |
|
dean.pask
UK
Posts |
Posted - 10/18/2005 : 09:51:30 AM
|
Mike,
Looks like it works almost.. It takes my Data from FFT data wks although it then displays the result on that FFT data wks.. Do I need to make the graph the current active item to display it on there?
My deepest thanks as ever.
Dean
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/18/2005 : 10:32:44 AM
|
Dean,
Yes, the graph window must be active. Following script assumes graph is active and peak X&Y are stored in columns Pkx&Pky of FFT wks.
%W=%[%C,'_']; // get name of the FFT wks from active dataplot if( exist(%W_Pkx,1)==0 ) { ty -a No peaks!; return; }; get %W_Pkx -e nPeaks; // # of peaks if( nPeaks==0 ) { ty -a No peaks!; return; }; loop (ii,1,nPeaks) { xx=%W_Pkx[ii]; // pk position yy=%W_Pky[ii]; // pk height label -s $(xx); // create text label doc -e G { // find its name - will be the first match encountered if("%[%B,5]"=="text") break; }; %B.x = xx; // move center of label to X = xx %B.y = yy + %B.dy; // move center to Y = yy + labelHeight };
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 10/18/2005 10:48:59 AM |
 |
|
dean.pask
UK
Posts |
Posted - 10/23/2005 : 10:45:07 AM
|
Hay Mike,
Using the code below leaves me with the FFT of Data1 (first run) as the open window.... How do I reopen the fft graph which is the one before this?
Thanks again.
%L=%H; // save its name wks.col1.type=4; worksheet -s 2 0 2 0; worksheet -p 200 Origin;
layer -a; window -t W FFT; %F=%H; // save its name page.label$=FFT of %L; // identify Labview data in label page.title=3; // show label
fft.reset(); fft.forward = 1; fft.forward.timeData$ = %L_A; fft.forward.tdelta = %L_A[2] - %L_A[1]; fft.forward.realData$ = %L_B; fft.output.samplingdata$ = %F_Freq; fft.output.realdata$ = %F_Real; fft.output.imagdata$ = %F_Imag; fft.output.ampdata$ = %F_r; fft.output.phasedata$ = %F_Phi; fft.output.powerdata$ = %F_Power; fft.real = 1; fft.normalize = 1; fft.shifted = 1; fft.windowing = 1; fft.spectrum = 1; fft.unwrap = 1; fft.forward();
worksheet -s 4 0 4 0; worksheet -p 200 Origin; layer1.y.from = 0; layer1.x.from = 0; layer1.x.to = 3E9; layer1.y.to = 10;
nPeaks=5; %B=%F_r; win -t D; // create temporary wks %W=%H; // save its name wks.addcol(Pki); // add col for peak indices curve.pickpeaks.simple=1; curve.reset(); curve.data$=%B; curve.peakIndex$ = %W_Pki; curve.pickPeaks.rectHeight = 0.005; curve.pickPeaks.rectWidth = 0.005; curve.pickPeaks.minHeight = 0.005; curve.pickPeaks(1);
get %W_Pki -e end; if(end==0) { type -a No peaks were found.; win -cd %W; return; };
nn=0; for(ii=1;ii<=end;ii++) { index = %W_Pki[ii]; xx = xvalue(index,%B); if( xx<0 ) continue; nn++; %W_A[nn] = xx; %W_B[nn] = %B[index]; }; type -a $(nn) peak/s were found;
if(nn>nPeaks) { sort -wd %W %W_B; set %W -er nPeaks; sort -w %W %W_A; };
if(nn>0) { win -a %F; // activate FFT wks wks.addCol(Pki); wks.addCol(Pkx); wks.addCol(Pky); copy %W_Pki %H_Pki; copy %W_A %H_Pkx; copy %W_B %H_Pky; };
win -cd %W; // delete temporary wks
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 10/23/2005 : 11:27:04 AM
|
Hi Dean,
You need to save the graph's window name in a string variable and activate at the end. Looks like the FFT graph is created in the fourth code section which should therefore be changed to this...
worksheet -s 4 0 4 0; worksheet -p 200 Origin; %P=%H; // save graph name layer1.y.from = 0; layer1.x.from = 0; layer1.x.to = 3E9; layer1.y.to = 10;
Then you can restore the graph window with this command...
win -a %P; // activate FFT graph
Mike Buess Origin WebRing Member |
 |
|
|
Topic  |
|