How to convert this mesh as 3d matrix?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
shubham kumar gupta
le 22 Nov 2022
Réponse apportée : Cris LaPierre
le 22 Nov 2022
AIM : I want to get a 3d plane for this plane as PLANE3D(i,j,k)
I tried creating a meshgrid of xy then added z data
[x y] = meshgrid(0:0.01:4); % Generate x and y data
z = zeros(size(x, 1)); % Generate z data
hs=surf(x, y, z); % Plot the surface
%or
hs=mesh(x,y,z)
Now hs will be having XData, YData, & ZData
Now I did this to get a 3d Matrix
XYZ=[hs.XData; hs.YData; hs.ZData] % PLANE3d
figure,mesh(XYZ)
0 commentaires
Réponse acceptée
Cris LaPierre
le 22 Nov 2022
Not exactly sure what the question is, but note that XYZ is not the same as (x,y,z). In XYZ, x and y values are your index number, and Z is the values of the matrix. So in the first 401 rows the values show a steady ramp from 1-401 in x, the next 401 rows show a steady ramp from 1-401 in the y direction, and then the last 401 rows are your original Z values of 0.
If you are trying to capture the data in 3D (first sheet is X, 2nd sheet is Y, 3rd sheet is Z), you either need to explicitly assign the data sheet by sheet
XYZ(:,:,1) = x;
XYZ(:,:,2) = y;
XYZ(:,:,3) = z;
or you need to use reshape.
XYZ=[hs.XData; hs.YData; hs.ZData] % PLANE3d
XYZ = reshape(XYZ,length(x),length(y),[])
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!