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 个)

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 个评论

Thank you!
These were all good options.
Is there a way to get the same type of plot as scatter plot, or like one figure of plotmatrix ?
I want to see illustrate the trade-off, between A and B
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!

Translated by