Cant plot with "if/else"

1 view (last 30 days)
Daniel
Daniel on 13 May 2015
Commented: Daniel on 13 May 2015
Hey I'm trying to plot this
x = To:It:Tf;
if x <= 411;
a = 2.03 + (0.0390*x);
else x > 411;
a = 12 + (.00273*x);
end
b = 12.62+(0.001492*x)-(76200./(x.^2));
c = (C1/100)*a + (C2/100)*b;
plot(x,a,'-',x,b,'--',x,c,'.');
But when I try to plot it, it only takes value of the second formula for a, anyway I can make the if/else condition work? Thanks!
  2 Comments
Purushottama Rao
Purushottama Rao on 13 May 2015
What is the value of Tf?
Daniel
Daniel on 13 May 2015
Oh sorry To is 273, It is 5 and Tf is 498, thanks

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 13 May 2015
x = To:It:Tf;
smallx = x <= 411;
a(smallx) = 2.03 + 0.0390*x(smallx);
a(~smallx) = 12 + 0.00273*x(smallx);
  1 Comment
Daniel
Daniel on 13 May 2015
Thanks a lot! This really fixed it!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!