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
Eric 2012년 8월 9일
Do you realize that you said you have two questions and yet didn't ask any questions?
Peyman
Peyman 2012년 8월 9일
편집: Peyman 2012년 8월 9일
Corrected it. means we are going somewhere, though no result yet

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
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
Peyman
Peyman 2012년 8월 9일
Sorry about that and thank you so much.
What debugger do you suggest.
I didn't follow at the end, what did you leave to me?! You already did it!
Image Analyst
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 CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by