I would like to use this command. I want to to a contour plot of a square figure. X is the vector who represent the x coordinates of the square figure and Y is a vector who represent the y coordinates of the square figure? If a have a square figure what I have to assume for X and Y inputs?
surf(X,Y,Z)
Matlab said that Z must be a matrix and not a vector. What's the matter?

 채택된 답변

Mischa Kim
Mischa Kim 2014년 3월 5일
편집: Mischa Kim 2014년 3월 5일

1 개 추천

Francesco, that is correct. Z must be a matrix, see for example (from the documentation)
[X,Y] = meshgrid(-8:.5:8); % create 33-by-33 matrices for X and Y
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R; % note, Z is also a 33-by-33
surf(X,Y,Z)
where meshgrid is used to create matrices for X and Y. Based on the grid you can compute/assign values to Z .

댓글 수: 4

Francesco
Francesco 2014년 3월 5일
편집: Francesco 2014년 3월 5일
But If a have only a vector How can I do it? My Z variable is a column vector. How can I do?
Francesco
Francesco 2014년 3월 5일
Kim, I have a square figure. Inside this figure there are some points. At each point inside the square it's associated a numeric value. My goal is to create a map of shades where the highest values are of a certain color (red for example) and the lowest values are of a different one. In practice it is what the leterature said "contour plot". So, I have some points inside the square figure and for each points I have the related numeric values. How do I so the contour plot?
Walter Roberson
Walter Roberson 2014년 3월 5일
Like I have told you several times before: use griddata() or trisurfinterp() or scatteredinterpolant()
Francesco
Francesco 2014년 3월 5일
I don't have trisurfinterp() or scatteredinterpolant() commands on my MATLAB. I have only griddata(). I have to investigate it!

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

추가 답변 (0개)

카테고리

태그

질문:

2014년 3월 5일

댓글:

2014년 3월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by