How can I plot rows from different matrices?

6 ビュー (過去 30 日間)
Irene del Mar Farinas Lucas
Irene del Mar Farinas Lucas 2020 年 5 月 21 日
コメント済み: Walter Roberson 2020 年 5 月 21 日
I have two matrices (x and y), both being 13x5. I need to plot all possible combinations of each row of x with each row of y. I have done:
plot(x(1,1:5),y(1:13,1:5))
But I don't want to go one by one:
plot(a(2,1:5),y(1:13,1:5))
plot(a(3,1:5),y(1:13,1:5))
etc
Could you help me?
This is the code I've done so far:
b=5
c=10
x=[b b 0 0 b]
y=[0 c c 0 0]
xvector=-(6*b):b:6*b
xvector=xvector'
xcoordinates=xvector+x
yvector=-(6*c):c:6*c
yvector=yvector'
ycoordinates=yvector+y
plot(xcoordinates(1,1:5),ycoordinates(1:13,1:5),"Linewidth", 3)
hold on
plot(xcoordinates(2,1:5),ycoordinates(1:13,1:5),"Linewidth", 3)
xlim([-(6*b) 6*b]); ylim([-(6*c), 6*c])
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 21 日
hold on
arrayfun(@(R) plot(x(R,1:5), y(1:13,1:5).'), 1:size(x,1))
hold off

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

採用された回答

darova
darova 2020 年 5 月 21 日
Use for loop
for i = 1:12
for j = i+1:13
line(x(i,:),y(j,:),'color',rand(1,3))
end
end

その他の回答 (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