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

Réponses (2)

Star Strider
Star Strider le 11 Juin 2019
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 commentaires

Ingrid Elisaebeth Glestad
Ingrid Elisaebeth Glestad le 11 Juin 2019
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 ?
Ingrid Elisaebeth Glestad
Ingrid Elisaebeth Glestad le 11 Juin 2019
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by