How can I do contour plot?

1 回表示 (過去 30 日間)
Francesco
Francesco 2014 年 3 月 5 日
コメント済み: Francesco 2014 年 3 月 5 日
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 日
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 件のコメント
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 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by