how do i plot til some x one function and then other

1 view (last 30 days)
i want to plot plz help
y = { x x<=12
12 x>12 }

Accepted Answer

Stephen23
Stephen23 on 22 Oct 2020
Edited: Stephen23 on 22 Oct 2020
x = 0:0.1:20;
y = min(12,x);
plot(x,y,'-+')
In a more general case, use logical indexing, e.g.:
x = 0:0.1:20;
y = x;
y(y>12) = 12;

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!