How to draw lines through elements with same value

4 ビュー (過去 30 日間)
James Lorringer
James Lorringer 2015 年 9 月 9 日
コメント済み: James Lorringer 2015 年 9 月 9 日
Hello! I have a small question here:
Suppose I have a matrix A, it looks like:
1 2 3 4 5 6 7
2 1 3 5 4 6 9
4 1 3 8 6 7 5
Now I want to plot the lines through points with value=1 and value=5 into a 2D plot, where x axis is created by for loop:
for i = 10:1:17;
end
and y axis is created by for loop:
for j = 2.5:0.1:2.7;
end
Can someone help me on this? It is possible to make the lines as smooth as possible?
Thanks a lot!

採用された回答

Walter Roberson
Walter Roberson 2015 年 9 月 9 日
selected = (A==1) | (A==5);
image(selected, 'XData', [10 16], 'YData', [2.5 2.7]);
Possibly you would prefer
contour(10:16, 2.5:0.1:2.7, A, [1 5])
Note my correction of the 10:17 to 10:16 as you only have 7 elements rather than 8
  3 件のコメント
Walter Roberson
Walter Roberson 2015 年 9 月 9 日
[C,h] = contour(10:16, 2.5:0.1:2.7, A, [1 5]);
clabel(C,h);
James Lorringer
James Lorringer 2015 年 9 月 9 日
Great! Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by