How to change plotyn plot curve lines to stairs line

2 ビュー (過去 30 日間)
davit petraasya
davit petraasya 2016 年 3 月 4 日
コメント済み: manoharb 2016 年 3 月 18 日
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?
Thanks!
  1 件のコメント
manoharb
manoharb 2016 年 3 月 18 日
Please attach working m. file of plotyn

サインインしてコメントする。

採用された回答

Jos (10584)
Jos (10584) 2016 年 3 月 4 日
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
  3 件のコメント
Jos (10584)
Jos (10584) 2016 年 3 月 4 日
I do not have the function plotyn.
However, I assume that hlines(k) is the graphics handle to the plot of (xk,yk). You could try to do the following if you want to plot the points given by, for instance, (x3,y3) as a stair:
[ax,hlines] =plotyn(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,labels)
[XX,YY] = stairs(x3,y3)
set(hlines(3), 'xdata',XX, 'ydata','YY)
davit petraasya
davit petraasya 2016 年 3 月 4 日
This is great! Thanks Jos, it is working!

サインインしてコメントする。

その他の回答 (1 件)

Star Strider
Star Strider 2016 年 3 月 4 日
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 件のコメント
davit petraasya
davit petraasya 2016 年 3 月 4 日
Thanks Star,I modified a bit plotyn version of my code as Jos adviced above and it is working .

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBiotech and Pharmaceutical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by