Plotting two matrixes in same plot
显示 更早的评论
I would like to make a good plot for plotting two matrixes, both 300x19.
A = 300x19
B= 300x19
I was thinking somthing like scatter(A, B), but this do not seem to work. Get the following error "X and Y must be vectors of the same length."
Plot(A, B) does not provide the inforamtion in a good way.
Thanks,
Ingrid
回答(2 个)
KALYAN ACHARJYA
2019-6-11
surf(A,B)
Star Strider
2019-6-11
I am not certain what result you want..
One option:
figure
plot(A)
hold on
plot(B)
hold off
If you want them oriented differently, transpose them:
figure
plot(A')
hold on
plot(B')
hold off
You can also use scatter in place of plot if that is what you want.
If you want to plot every row of ‘A’ against the corresponding row of ‘B’:
figure
hold all
for k = 1:size(A,1)
plot(A(k,:), B(k,:))
end
hold off
3 个评论
Ingrid Elisaebeth Glestad
2019-6-11
Ingrid Elisaebeth Glestad
2019-6-11
Star Strider
2019-6-11
My pleasure!
Probably the best option would be something like this:
figure
hold all
for k = 1:size(A,1)
scatter(A(k,:), B(k,:), 'filled')
end
hold off
I am still not certain what you want, however. The problem is that most of the plot functions want more than one argument, so simply plotting a matrix is not straightforward. It is likely necessary to plot individual rows or columns against each other. That is similar to what plotmatrix does.
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!