How to plot graph constant in Matlab?
13 views (last 30 days)
Show older comments
Fieldza Field
on 20 Jun 2015
Commented: Fieldza Field
on 20 Jun 2015
If I want plot graph same picture ,How to write code.
0 Comments
Accepted Answer
Walter Roberson
on 20 Jun 2015
function r = Y(x)
r = zeros(size(x));
r(x<5) = -10;
r(x>10) = 15;
end
but now you need to decide what value you want to return if x is exactly 5 or exactly 10. Or at least you do if you want to do this in terms of a function.
If you just need it as a graph and not as a function, then let lowx be the lowest x to plot from, and highx to be the highest x to plot to, and then
plot([lowx 5 5 10 10 highx], [-15 -15 0 0 10 10]);
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots 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!