Draw a discontinuous line

12 ビュー (過去 30 日間)
Orongo
Orongo 2018 年 10 月 24 日
コメント済み: jonas 2018 年 10 月 24 日
Hi, I want to draw a discontinuous line that will later be used in a another plot. For my example I have written following lines
y1 = [0.6 0.6];
y2=[0.3 0.3];
x1 = [0.7 1.3];
x2=[1.8 2.2];
line(x1,y1); hold on
line(x2,y2); hold off
This is fine for 2 lines but I have more. Can this be written differently? Say for example for 10 discontinuous lines?
  1 件のコメント
Adam
Adam 2018 年 10 月 24 日
You can put your x1, x2,... and y1, y2,... into matrices and loop around the relevant dimension, plotting each piecewise.

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

採用された回答

jonas
jonas 2018 年 10 月 24 日
編集済み: jonas 2018 年 10 月 24 日
Do not use indexed variable names. Build a 2xn matrix instead.
x =
0.7000 1.8000
1.3000 2.2000
y =
0.6000 0.3000
0.6000 0.3000
Build a matrix instead
plot(x,y);
  2 件のコメント
Orongo
Orongo 2018 年 10 月 24 日
Thanks exactly what I was looking for!
jonas
jonas 2018 年 10 月 24 日
Cheers!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by