3d mesh from vector points
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I need help creating a 3d surface mesh for X, Y, Z data points (file provided) and I believe the Z values are vector numbers not matrix
Thanks!
0 commentaires
Réponse acceptée
Voss
le 5 Jan 2024
unzip('formica 50x.asc.zip')
M = readmatrix('formica 50x.asc','FileType','text','Delimiter','\t');
% the file contains two sets of data separated by two lines of text that
% contain some description or something (lines 307208 and 307209, which
% correspond to NaNs in the first column of M), so split M into two
% matrices M1 and M2 using the locations of those NaN values.
idx = find(isnan(M(:,1)));
M1 = M(1:idx(1)-1,:);
M2 = M(idx(2)+1:end,:);
% find the number of consecutive repeated X values in each section of M1,
% and use that to get the number of distinct Y values.
nx = diff(find(diff(M1(:,1))));
assert(all(nx == nx(1)))
nx = nx(1);
ny = size(M1,1)/nx;
% use those sizes to reshape each column of M1.
X = reshape(M1(:,1),nx,ny);
Y = reshape(M1(:,2),nx,ny);
Z = reshape(M1(:,3),nx,ny);
% plot a surface.
figure
subplot(2,1,1)
surf(X,Y,Z,'EdgeColor','none')
xlabel('X')
ylabel('Y')
zlabel('Z')
% now do the same for M2.
nx = diff(find(diff(M2(:,1))));
assert(all(nx == nx(1)))
nx = nx(1);
ny = size(M2,1)/nx;
X = reshape(M2(:,1),nx,ny);
Y = reshape(M2(:,2),nx,ny);
Z = reshape(M2(:,3),nx,ny);
subplot(2,1,2)
surf(X,Y,Z,'EdgeColor','none')
xlabel('X')
ylabel('Y')
zlabel('Z')
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
