필터 지우기
필터 지우기

How to create a Contour plot?

조회 수: 1 (최근 30일)
Ashley
Ashley 2013년 10월 13일
댓글: sixwwwwww 2013년 10월 14일
Hello, I need to create a contour plot of a column vector, but keep getting the error that Z must be a 2X2 matrix. Is there any way of just arbitrarily assigning another column to Z data and going ahead with the plotting?
So far, my Z matrix has 1 column and 233 rows. I have to basically create a pseudosection(contour of Z) vs. depth which goes up to 13.5 meters and horizontal distance along ground that is 27 m. Please help, am willing to provide any other information if it helps. Thank you.
Ashley
  댓글 수: 3
Image Analyst
Image Analyst 2013년 10월 14일
Yes, provide the other information because I've read your post 5 times and can't figure it out. http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Ashley
Ashley 2013년 10월 14일
Hello, I have X,Y and Z matrices which are basically 234 X 1 Column Vectors. It keeps saying that I have to have Z be a 2X2 matrix, and that X needs to match the number of columns in Z, etc. How do I make a 2X2 matrix out of a 234 X 1 column vector? Hope this makes sense. Thank you. Ashley

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

답변 (1개)

sixwwwwww
sixwwwwww 2013년 10월 14일
Dear Ashley, in order to create contour plot you need to have Z as a matrix not as a vector. Also if you have X and Y vectors of 234 length then you will need Z a matrix of size 234x234 to use
contour(X, Y, Z)
See for more information about "contour": http://www.mathworks.com/help/matlab/ref/contour.html Otherwise you need to use plot3 accept Z as a vector as in your case
plot3(X, Y, Z)
See for more information about "plot3": http://www.mathworks.com/help/matlab/ref/plot3.html
  댓글 수: 2
Ashley
Ashley 2013년 10월 14일
Hello, Yes, however that is my question! How do I create a 234X234 matrix out of a 234X1 column vector? Is there a function or way of doing this? Thank you.
Ashley
sixwwwwww
sixwwwwww 2013년 10월 14일
You can repeat Z vector 234 times like this:
Z = rand(234,1); % put your Z vector here
ZZ = zeros(length(Z), length(Z));
for i = 1:length(Z)
ZZ(:,i) = Z(:);
end

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

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by