T O P I C R E V I E W |
dean.pask |
Posted - 11/01/2005 : 6:29:36 PM Origin Version (Select Help-->About Origin): 7.5 Operating System: xp
Hi all,
My program with large amounts of help from Mike is below which works amazing.. I have found that my FFTs are skewed and require interpolating then curve fitting (non linear curve fitting - peak functions - gauss)... my question as ever is how do I do this in my code?
Super thanks in advance again.
Dean
%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 = 3; fft.spectrum = 1; fft.unwrap = 1; fft.forward();
worksheet -s 4 0 4 0; worksheet -p 200 Origin; %P=%H; // save graph name layer1.y.from = 0; layer1.x.from = 2E8; layer1.x.to = 3E9; layer1.y.to = 0.5;
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
win -a %P; // activate FFT graph
%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 };
|
1 L A T E S T R E P L I E S (Newest First) |
Mike Buess |
Posted - 11/02/2005 : 09:11:51 AM Hi Dean,
If linear interpolation is sufficient you can use the Table() function. Not sure where you want to do this but assume your FFT data are in cols Freq(X) and r(Y) of wks FFT1. Create a new wks (Data2), fill A(X) with the new frequency values and run this command...
Data2_B = Table(FFT1_Freq, FFT1_r, Data2_A);
If more sophisticated interpolation is required you can use the Curve Spline Interpolate function here... http://www.originlab.com/index.aspx?s=8&lm=243
Mike Buess Origin WebRing Member |
|
|