How to rule out (filter for a continuous function) some output data?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Eric
il 9 Ago 2012
Do you realize that you said you have two questions and yet didn't ask any questions?
Risposta accettata
Image Analyst
il 9 Ago 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 Commenti
Image Analyst
il 9 Ago 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Entering Commands in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!