フィルターのクリア

How to plot a horizontal line between two arrays?

2 ビュー (過去 30 日間)
Wolfgang McCormack
Wolfgang McCormack 2021 年 3 月 12 日
コメント済み: Star Strider 2021 年 3 月 12 日
Hi all,
I have the following arrays, I want to draw a horziontal line between each row. Could someone please teach me how to do that?
A = [5:1:45]
B = [10:1:50]
So what I want is a horzintal/flat line between each point of A and B. For instance a flat line for A(1)=5 at a Y of 1 extended to B(1)=10 at the same Y. Like the image below:
Thanks in advance
  3 件のコメント
Wolfgang McCormack
Wolfgang McCormack 2021 年 3 月 12 日
@Star Strider sorry, that was a mistak they are having the same lenght. I corrected it.
Star Strider
Star Strider 2021 年 3 月 12 日
Not in time for me to see it and post an Answer.

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

採用された回答

ANKUR KUMAR
ANKUR KUMAR 2021 年 3 月 12 日
Question is not clear. Quoting on a part of your question, " flat line for A(1)=5 at a Y of 1 extended to B(1)=10 at the same Y"
A and B should have the same dimension, and you must have a y values of corresponding A or B.
A=randi(10,1,6);
B=A+randi(5,1,6);
y=[1:6];
for ii=1:length(A)
plot([A(ii) B(ii)],ones(1,2)*y(ii),'k-o')
hold on
end

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by