How to change plotyn plot curve lines to stairs line

3 views (last 30 days)
davit petraasya
davit petraasya on 4 Mar 2016
Commented: manoharb on 18 Mar 2016
I have 5 curve line, I have got them using plotyn.(see attached plot) I need to change the 5 line curves to stairs type line. How I can do it?

Accepted Answer

Jos (10584)
Jos (10584) on 4 Mar 2016
Can't you use STAIRS? An example:
x = 0:.2:pi/2 ;
y = sin(x) ;
plot(x,y,'bo-') ;
hold on ;
stairs(x,y,'r.-') ;
hold off

Sign in to comment.

More Answers (1)

Star Strider
Star Strider on 4 Mar 2016
Consider using the interp1 function with the 'nearest' method on your data, then plot the result produced by interp1 as a function of the interpolation vector you used. Experiment with it to get the result you want. It should give you the ‘stairs’ effect.
Otherwise, you would have to hack into the code for the plotyn version you are using, and substitute stairs for plot. I don’t suggest modifying someone else’s code unless you thoroughly understand how it works.
  1 Comment
davit petraasya
davit petraasya on 4 Mar 2016
Thanks Star,I modified a bit plotyn version of my code as Jos adviced above and it is working .

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!