Why I can not do this surf?

3 ビュー (過去 30 日間)
Ayob
Ayob 2014 年 1 月 19 日
編集済み: Image Analyst 2014 年 1 月 19 日
I have made three matrices X,Y and Z. All of them are 144*1 matrices. I use surf(X,Y,Z), but it doesn't work!
[EDIT] Ayob "Answered" his own question with this, but I moved it up here since it's not an answer:
I have X, Y and Z matrices. How can I change X, Y and Z to the forms that enable me use surf? I have all nodes but in (x,y,z) shape.
  1 件のコメント
Paul
Paul 2014 年 1 月 19 日
need more info on how those vectors look like. is it like
x= [1 2 3 4 1 2 3 4 1 2 3 4]'
If the nodes are not equally distributed you'll still need to interpolate like in my other comment.

サインインしてコメントする。

回答 (2 件)

Paul
Paul 2014 年 1 月 19 日
Because Z should be a 144*144 matrix. 1 value for each pair of x and y values.
  2 件のコメント
Ayob
Ayob 2014 年 1 月 19 日
編集済み: Ayob 2014 年 1 月 19 日
This is not exactly what I want. What other function should I use?(I have my vales in x,y,z which are in (X,Y,Z).
Paul
Paul 2014 年 1 月 19 日
Sounds like you have scattered data, need more info on that. You can probably interpolate the data using griddata to a desired grid like this:
[xq,yq] = meshgrid(-2:.2:2, -2:.2:2);
zq = griddata(x,y,z,xq,yq);
surf(xq,yq,zq)
Where xq and yq are the desired interpolation points.

サインインしてコメントする。


Image Analyst
Image Analyst 2014 年 1 月 19 日
If you have only a few scattered points here and there, and these are listed in your x,y,z array, then you need to use the griddedInterpolant class. It will estimate z values for the missing coordinate locations and build a complete surface.
  1 件のコメント
Image Analyst
Image Analyst 2014 年 1 月 19 日
編集済み: Image Analyst 2014 年 1 月 19 日
If you have older versions of MATLAB, use griddata() or TriScatteredInterp(). These are deprecated (not recommended, and scheduled to be eliminated) and the new recommendation is to use griddedInterpolant.

サインインしてコメントする。

カテゴリ

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