How to rule out (filter for a continuous function) some output data?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
t1=[1:1:100]
p=xlsread('Jan2010.xls','B101:B200');
t2=[101:1:200]';
k(t2)=a1*sin(b1*t2+c1)+a2*sin(b2*t2+c2);
if k(t2) > max(p) || k(t2) < min(p);
k(t2)=k(t2-t1);
end
v=k(t2)';
error:
Operands to the || and && operators must be convertible to logical scalar values
when I change to |, it doesn't show any error, but it doesn't have any effect on the function too.
How can I get rid of this error?
Anyway, I used another code (below); I didn't receive any error, however I didn't see any change in the result either!
if k(t2)>max(p)
k(t2)=k(t2-t1);
elseif k(t2)<min(p)
k(t2)=k(t2-t1);
end
I need this to rule out(filter) input data that is not relevant (because they are more than or less than 'max' or 'min' of p). so that when I draw the function k(t2) the final values of k doesn't exceed max and min of p.
How can I get rid of some particular results that a functions shows(the function is a sinusoidal diagram in this case)?
2 comentarios
Eric
el 9 de Ag. de 2012
Do you realize that you said you have two questions and yet didn't ask any questions?
Respuesta aceptada
Image Analyst
el 9 de Ag. de 2012
Maybe try it like this:
if k(t2) > max(p) || k(t2) < min(p) % Semicolon not needed.
k(t2) = k(t2 - 1); % Set to previous element.
end
12 comentarios
Image Analyst
el 9 de Ag. de 2012
MATLAB has a built in debugger. See some of Doug Hull's video tutorials on the web site - he has a blog. I did not handle the case where k(1) is a bad value but you see how to do it from the inside of the for loop.
Más respuestas (0)
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!