T O P I C R E V I E W |
tomblue |
Posted - 06/26/2007 : 10:07:07 AM Origin Version (Select Help-->About Origin): 7.5 Operating System: win xp pro sp2 core 2 duo 4GB
Hi all,
I would like to set up a script obtaining the mean of many cols (mean for each col) in a wks and additionally perform FFT on them. Now, is it possible or useful to take the 'sum' command? I thought using something like this:
for(ii=2; ii<=%(data1,@#); ii++) { sum(data1,@#); data2_b[ii]=sum.mean; };
Of course it returns 'command error'. Shouldn't it be just like perform the command and read out the desired value? I am not familiar with programming and do not understand what is to be done in order to get the script to work properly.
Thanks in advance for helping me...
Best regards Tom |
6 L A T E S T R E P L I E S (Newest First) |
tomblue |
Posted - 07/02/2007 : 02:05:19 AM Hi Mike,
this fine - thx a lot!
Best regards Tom |
Mike Buess |
Posted - 06/29/2007 : 08:45:53 AM quote: fft.forward.realData$ = %(Data1,ii);
This does not work. Result is still empty.
Two more mistakes... 1. There's an unneeded semicolon at the end of the FOR condition which prevents execution. 2. Datasets are named wrong for fft.forward.tdelta.
quote: What about the new fft-wks which is named FFT1 - I think it has to be changed in order to get a new different wks everytime a new fft is started. I will try to do it with enumerate.
Use the getenumwks macro...
for(ii=2; ii<=%(data1,@#); ii++) { fft.reset(); fft.forward = 1; fft.forward.timeData$ = %(Data1,1); fft.forward.tdelta = %(Data1,1)[2] - %(Data1,1)[1]; fft.forward.realData$ = %(Data1,ii); getenumwks FFT; fft.output.samplingdata$ = %H_Freq; fft.output.realdata$ = %H_Real; fft.output.imagdata$ = %H_Imag; fft.output.ampdata$ = %H_r; fft.output.phasedata$ = %H_Phi; fft.output.powerdata$ = %H_Power; fft.real = 1; fft.normalize = 1; fft.shifted = 1; fft.windowing = 1; fft.spectrum = 1; fft.unwrap = 1; fft.forward(); };
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 06/29/2007 09:04:55 AM |
tomblue |
Posted - 06/29/2007 : 04:11:41 AM So I have to change
fft.forward.realData$ = %(Data1,@#);
into
fft.forward.realData$ = %(Data1,ii);
This does not work. Result is still empty.
What about the new fft-wks which is named FFT1 - I think it has to be changed in order to get a new different wks everytime a new fft is started. I will try to do it with enumerate.
Thx.
Tom |
Mike Buess |
Posted - 06/28/2007 : 08:03:01 AM The problem and solution are the same as before: you're using the wrong terminology to identify the datasets. %(data1, @#) is the number of columns. Use %(data1,ii) to identify the iith column.
Mike Buess Origin WebRing Member |
tomblue |
Posted - 06/28/2007 : 05:50:20 AM Hi Mike,
thx, works fine. Another question is how to change the following script to get a loop performing fft on several cols in a wks? There maybe different time/x-cols - this seems to make it even more difficult.
--------------------------------------------------------- for (ii=2; ii<=%(data1,@#); ii++); { fft.reset(); fft.forward = 1; fft.forward.timeData$ = Data1_A; fft.forward.tdelta = Data1[2] - Data1[1]; fft.forward.realData$ = %(Data1,@#); //?? window -t W fft FFT1; fft.output.samplingdata$ = FFT1_Freq; fft.output.realdata$ = FFT1_Real; fft.output.imagdata$ = FFT1_Imag; fft.output.ampdata$ = FFT1_r; fft.output.phasedata$ = FFT1_Phi; fft.output.powerdata$ = FFT1_Power; fft.real = 1; fft.normalize = 1; fft.shifted = 1; fft.windowing = 1; fft.spectrum = 1; fft.unwrap = 1; fft.forward(); }; ---------------------------------------------------------
The result is an fft-wks, but empty. Where is it to be corrected? Please help - enough to realize only one time-axes (only 1st col), but would be nice to see - in order to understand - how to realize it datasets having different time-cols.
Thanks
Best wishes Tom |
Mike Buess |
Posted - 06/26/2007 : 11:15:14 AM Hi Tom,
%(data1, @#) returns the total number of columns in data1 but data1, @# by itself means nothing. Use %(data1, ii) to refer to the iith column of data1...
for(ii=2; ii<=%(data1,@#); ii++) { sum(%(data1,ii)); data2_b[ii]=sum.mean; };
Mike Buess Origin WebRing Member |
|
|