3D surface plot from only scalars

조회 수: 2 (최근 30일)
Kseniia
Kseniia 2023년 11월 21일
편집: Voss 2023년 11월 21일
Hi,
I am trying to recreate 4 3D surface plots which are essentially just slightly bent plancks. I do not have an expression for Z in terms of X and Y. What I do have is values of x, y and z at 10 points which outline the shape of the plancks in 4 different situations ( hence 4 sets of z values).
I have tried goimg around Z needing to be a matrix by using reshape, but my plot was very bizzare as a result.
x = [125, 125, 330, 335, 542.42, 545, 745, 750, 955, 957]
y = [90, -70, 65.983, -50, 55, -38, 40, -20, 30, -12 ]
z1 = [0.05215147, 0.027997192, -0.159427651, -0.101280145, -0.308593492, -0.297662702, -0.109720846, -0.161925999, 1, 0.878881731]
z2 = [0.111589723, -0.158663153, 0.248492373, 0.230284295, -0.107353165, 0.34547712, -0.985303806, -0.226828156, -0.093756651, 1]
z3 = [-0.15556355, 0.078821456, 0.105410656, 0.104914199, 0.228553441, 0.019881282, 0.108364212, -0.526927366, 1, -0.537000396]
z4 = [-0.174639769, 0.138819057, 0.138451162, -0.451431725, 1, -0.187467043, -0.063909498, -0.42369244, -0.295996076, 0.816359066]
xr = reshape(x, [], 5);
yr = reshape(y, [], 5);
z1r = reshape(z1, [], 5);
surf(xr, yr, z1r)
colorbar
will be very grateful for any help!
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 11월 21일
How do you get these values?
The values do not seem to be correct, as the Mode 1 image looks like it has parallel edges, where as the surface you have plotted has tapered edges.
Are the axis scales in the surface you have plotted the same as scales of the reference surface?

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

답변 (2개)

Star Strider
Star Strider 2023년 11월 21일
The only difference appears to be that whatever produced the plots in the posted image is using much higher precision and different scaling than is available to you.
Experimenting with the daspect function gives a more representative result —
x = [125, 125, 330, 335, 542.42, 545, 745, 750, 955, 957];
y = [90, -70, 65.983, -50, 55, -38, 40, -20, 30, -12 ];
z1 = [0.05215147, 0.027997192, -0.159427651, -0.101280145, -0.308593492, -0.297662702, -0.109720846, -0.161925999, 1, 0.878881731];
z2 = [0.111589723, -0.158663153, 0.248492373, 0.230284295, -0.107353165, 0.34547712, -0.985303806, -0.226828156, -0.093756651, 1];
z3 = [-0.15556355, 0.078821456, 0.105410656, 0.104914199, 0.228553441, 0.019881282, 0.108364212, -0.526927366, 1, -0.537000396];
z4 = [-0.174639769, 0.138819057, 0.138451162, -0.451431725, 1, -0.187467043, -0.063909498, -0.42369244, -0.295996076, 0.816359066];
xr = reshape(x, 2, []);
yr = reshape(y, 2, []);
z1r = reshape(z1, 2, []);
figure
surfc(xr, yr, z1r)
% G = daspect
daspect([1 0.5 1E-2])
colormap(turbo)
z2r = reshape(z2, 2, []);
figure
surfc(xr, yr, z2r)
daspect([1 0.5 1E-2])
colormap(turbo)
z3r = reshape(z3, 2, []);
figure
surfc(xr, yr, z3r)
daspect([1 0.5 1E-2])
colormap(turbo)
z4r = reshape(z4, 2, []);
figure
surfc(xr, yr, z4r)
daspect([1 0.5 1E-2])
colormap(turbo)
The application that produced the original plots needs to share all the details.
.

Voss
Voss 2023년 11월 21일
편집: Voss 2023년 11월 21일
x = [125, 125, 330, 335, 542.42, 545, 745, 750, 955, 957];
y = [90, -70, 65.983, -50, 55, -38, 40, -20, 30, -12 ];
z1 = [0.05215147, 0.027997192, -0.159427651, -0.101280145, -0.308593492, -0.297662702, -0.109720846, -0.161925999, 1, 0.878881731];
z2 = [0.111589723, -0.158663153, 0.248492373, 0.230284295, -0.107353165, 0.34547712, -0.985303806, -0.226828156, -0.093756651, 1];
z3 = [-0.15556355, 0.078821456, 0.105410656, 0.104914199, 0.228553441, 0.019881282, 0.108364212, -0.526927366, 1, -0.537000396];
z4 = [-0.174639769, 0.138819057, 0.138451162, -0.451431725, 1, -0.187467043, -0.063909498, -0.42369244, -0.295996076, 0.816359066];
xr = reshape(x, [], 5);
yr = reshape(y, [], 5);
z1r = reshape(z1, [], 5);
z2r = reshape(z2, [], 5);
z3r = reshape(z3, [], 5);
z4r = reshape(z4, [], 5);
figure
subplot(2,2,1)
surf(xr, yr, z1r, 'EdgeColor','none','FaceColor','interp','Marker','.','MarkerEdgeColor','k')
subplot(2,2,2)
surf(xr, yr, z2r, 'EdgeColor','none','FaceColor','interp','Marker','.','MarkerEdgeColor','k')
subplot(2,2,3)
surf(xr, yr, z3r, 'EdgeColor','none','FaceColor','interp','Marker','.','MarkerEdgeColor','k')
subplot(2,2,4)
surf(xr, yr, z4r, 'EdgeColor','none','FaceColor','interp','Marker','.','MarkerEdgeColor','k')

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by