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
 for-loop mean and FFT

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
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

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