Create 3D Surface

1 回表示 (過去 30 日間)
Kostas Chatz
Kostas Chatz 2012 年 2 月 13 日
編集済み: Cedric 2013 年 10 月 10 日
Hello,
I'm trying to create a 3D surface for simulation purposes. My code is:
function ZZ = plot_surface_test(Xl, width)
grid_points=6;
for i=1:grid_points*11
xx(i)=i/(grid_points*10);
for j=1:grid_points*11;
C(i,j)=0;
yy(j)=j/(grid_points*10);
ii=min(find((xx(i)-Xl(1,:)).^2+(yy(j)-Xl(2,:)).^2==min((xx(i)-Xl(1,:)).^2+(yy(j)-Xl(2,:)).^2)));
ZZ(i,j)=Xl(3,ii)*exp(-width(ii)*((xx(i)-Xl(1,ii)).^2+(yy(j)-Xl(2,ii)).^2));
end
end
surf(ZZ)
I would like some suggestions please according to what matrixes Xl and width should be so that this code generate a real-like surface.
Thank you

回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 2 月 13 日
Also, min(find(X)) can be replaced by find(X,1)

Kevin Holst
Kevin Holst 2012 年 2 月 13 日
It appears that Xl should be a 3x66 numeric matrix and width should be a 1x66. Xl(1,:) looks like it contains an x coordinate for a measurement, Xl(2,:) looks to contain the y coordinate, and Xl(3,:) contains the measurement. I'm not sure about width. It also lookes like you can get rid of C(i,j)=0; unless that's used somewhere later for something.
What else do you need to know about this?
  2 件のコメント
Kostas Chatz
Kostas Chatz 2012 年 2 月 13 日
I've tried numeric matrixes and the result is not a a real-like surface
Specificly i've put for Xl:
for i=1:grid_points;
for j=1:grid_points;
Xl(1,(i-1)*grid_points+j)=i/grid_points;
Xl(2,(i-1)*grid_points+j)=j/grid_points;
Xl(3,(i-1)*grid_points+j)=maximum_height_surface*rand;
end
end
but i don't have any idea for width.
I've tried an integer instead of vector width and the only thing i get is some random peaks that are not connected to each other.
Kevin Holst
Kevin Holst 2012 年 2 月 14 日
I just put in width = ones(1,66) and it worked for me. It produces a surface that has small curved square plateaus in a 6x6 square. Unfortunately, I'm not in a place where I can upload at screenshot. What are you expecting the surface to look like?

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

カテゴリ

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