Plotting two matrixes in same plot

조회 수: 1 (최근 30일)
Ingrid Elisaebeth Glestad
Ingrid Elisaebeth Glestad 2019년 6월 11일
댓글: Star Strider 2019년 6월 11일
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
KALYAN ACHARJYA 2019년 6월 11일
surf(A,B)

Star Strider
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
Ingrid Elisaebeth Glestad 2019년 6월 11일
I want to see illustrate the trade-off, between A and B
Star Strider
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile 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