Borrar filtros
Borrar filtros

For Loop Help Needed

2 visualizaciones (últimos 30 días)
Sarah
Sarah el 13 de Oct. de 2011
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.

Respuesta aceptada

David Young
David Young el 13 de Oct. de 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;
  1 comentario
Sarah
Sarah el 13 de Oct. de 2011
That did solve my error, but I don't think it gives me the solution that I want. For example, I essentially want the for loop to be able to do this:
The highest order is 4:
% T1.Prc = detrend(T1.Sig1,4);
% T2.Prc = detrend(T2.Sig1,4);
% T3.Prc = detrend(T3.Sig1,4);
% T4.Prc = detrend(T4.Sig1,4);
% T5.Prc = detrend(T5.Sig1,4);
%
% T1.Prc = detrend(T1.Prc,3);
% T2.Prc = detrend(T2.Prc,3);
% T3.Prc = detrend(T3.Prc,3);
% T4.Prc = detrend(T4.Prc,3);
% T5.Prc = detrend(T5.Prc,3);
%
% T1.Prc = detrend(T1.Prc,2);
% T2.Prc = detrend(T2.Prc,2);
% T3.Prc = detrend(T3.Prc,2);
% T4.Prc = detrend(T4.Prc,2);
% T5.Prc = detrend(T5.Prc,2);
% T1.Prc = detrend(T1.Prc,'linear');
% T2.Prc = detrend(T2.Prc,'linear');
% T3.Prc = detrend(T3.Prc,'linear');
% T4.Prc = detrend(T4.Prc,'linear');
% T5.Prc = detrend(T5.Prc,'linear');
%
% T1.Prc = detrend(T1.Prc,'constant');
% T2.Prc = detrend(T2.Prc,'constant');
% T3.Prc = detrend(T3.Prc,'constant');
% T4.Prc = detrend(T4.Prc,'constant');
% T5.Prc = detrend(T5.Prc,'constant');
^where linear and constant are 1 and 0 respectively

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by