How to rule out (filter for a continuous function) some output data?
조회 수: 2 (최근 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
Eric
2012년 8월 9일
Do you realize that you said you have two questions and yet didn't ask any questions?
채택된 답변
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!