Cant plot with "if/else"
1 view (last 30 days)
Show older comments
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
Accepted Answer
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);
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!