How to rule out (filter for a continuous function) some output data?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2012-8-9
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 个评论
Image Analyst
2012-8-9
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!