- A(i) outputs a scalar. You want A(:,i), which outputs the i:th column
- your code displayed a dot, which was difficult to see
how to subplot data from two matrix using for loop?
1 回表示 (過去 30 日間)
古いコメントを表示
I would like to use for loop to plot data from matrix A together with the corresponding column of matrix B using sub plot function. Below is my initial code. The problem is that I don't see any thing on the plots. Any help/suggestions would be appreciated.
X=1:1:100;
A=randi([1 10],100,3);
B=A+2;
hold on
for i=1:3
subplot(3,1,i)
plot(X,A(i));
plot(X,B(i));
end
0 件のコメント
採用された回答
per isakson
2017 年 8 月 18 日
編集済み: per isakson
2017 年 8 月 18 日
Problems with your code
Try
X=1:1:100;
A=randi([1 10],100,3);
B=A+2;
%
for i=1:3
subplot(3,1,i)
plot(X,A(:,i));
hold on
plot(X,B(:,i));
hold off
end
which creates
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!