How to remove the lines from a stairstep graph

After I have created a stairstep graph, MatLab automatically adds the vertical lines. How do I get rid of these vertical lines and so only the horizontal ones of the stairstep graph are there?

回答 (1 件)

José-Luis
José-Luis 2012 年 10 月 10 日

0 投票

x = 1:10;
y = x;
addX = arrayfun(@(x) [x NaN x],x(2:end),'uniformOutput',false);
x = [x(1) cell2mat(addX)];
addY = arrayfun(@(x) [x x x],y(1:end-1),'uniformOutput',false);
y = [cell2mat(addY) y(end)];
plot(x,y);

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

質問済み:

2012 年 10 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by