For Loop Help Needed
1 view (last 30 days)
Show older comments
Hey guysss,
So I am trying to write a for loop to automatically detrend my signal until the "constant" value, or 0. I am using an updated detrend function that allows for higher order detrending rather than just linear.
%Detrend
Order.Max = 5;
X = 0:Order.Max - 1;
X = sort(X,'descend');
T1.Prc = detrend(T1.Sig1,Order.Max);
T2.Prc = detrend(T2.Sig1,Order.Max);
T3.Prc = detrend(T3.Sig1,Order.Max);
T4.Prc = detrend(T4.Sig1,Order.Max);
T5.Prc = detrend(T5.Sig1,Order.Max);
for Order.Low = X,
T1.Prc = detrend(T1.Prc,Order.Low);
T2.Prc = detrend(T2.Prc,Order.Low);
T3.Prc = detrend(T3.Prc,Order.Low);
T4.Prc = detrend(T4.Prc,Order.Low);
T5.Prc = detrend(T5.Prc,Order.Low);
end
I keep getting this error: ??? Error: File: fieldanalysisPART1.m Line: 18 Column: 10 Unexpected MATLAB operator.
Can you help me correct this? I essentially want the for loop to detrend the original signal T1.Sig1 with the highest order (for example, Order.Max = 5) and save it to T1.Prc. Then, I want the for loop to detrend T1.Prc with 4,3,2,1, and 0.
0 Comments
Accepted Answer
David Young
on 13 Oct 2011
It would help if you told us which is line 18, but I'm guessing it's probably the one that says:
for Order.Low = X,
since this will provoke the error message you get.
The reason is that you need to provide a simple variable name for the for-loop. You should try replacing the line above with these two lines:
for x = X
Order.Low = x;
(omitting also the extraneous comma). There may be other problems, but that will at least deal with the message you're getting now.
As a side point, instead of
X = 0:Order.Max-1;
X = sort(X, 'descend');
you could write
X = Order.Max-1 : -1 : 0;
More Answers (0)
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!