Plots with stairs and inclines?

4 ビュー (過去 30 日間)
Thanos Maravel
Thanos Maravel 2017 年 4 月 24 日
コメント済み: Thanos Maravel 2017 年 4 月 24 日
Assume I need to create a plot including both gentle slides and abrupt steps, such as the attached plot (note the step-like drop at vertical 2 versus the incremental slope of vertical 2-3).
To my understanding, plot() only produces the latter, while stairs() the former. How can I produce both, aside from piecing it together using several 'identical but distinct' lines on the same figure (not optimal).

採用された回答

Andrew Newell
Andrew Newell 2017 年 4 月 24 日
I'm not sure how you intend to generate the points, but for the example plot you gave, plot works just fine with an appropriate input:
x = [0:2 2:5];
y = [0 1 2 1 -1 0 0];
plot(x,y)
axis([0 5 -3 3])
  1 件のコメント
Thanos Maravel
Thanos Maravel 2017 年 4 月 24 日
This works neatly! I had tried to assign them via formulas and use of 'for' since I was gonna multiply and sum a pair later, and their 'steps' were different, but with a little doing I figured I could give them the same steps. Thanks bunches!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by