Plotting an irregular closed 3D surface
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello!
First of all, I am thankful for all the advice 'MATLAB Answers' has given me in the past year. It has helped me in my current problem, but not fully, so I would be very appreciative of any ideas.
I am trying to render a visualization of a closed surface in spherical coordinates. This surface is not necessarily regular and therefore I had to define it piecewise rather than by predefined MATLAB functions. This resulted in a matrix whose elements are radial distances, R(i,j), where i and j are indexed theta and phi values from 0 to 2pi each.
When I try to plot R(i,j), I do not see the object I expect, though I am fairly sure R(i,j) is defined correctly. May you please take a look at my approach and tell me if there is something peculiar about it? Thanks!
My code is:
spacing = 2*pi/N;
Th = 0: 2*pi/spacing : 2*pi;
Phi = 0: 2*pi/spacing : 2*pi;
for (i,j such that R is on the first definition of the piecewise function)
assign R(i,j) = ...
end
for (i,j such that R is on the second portion)
assign R(i,j) = ...
end
% etc.
% Then create mesh
[Th_mesh, Phi_mesh] = meshgrid(Th, Phi);
% Convert to cartesian co-ordinates
[X,Y,Z] = sph2cart(Th_mesh, Phi_mesh, R(:,:));
% plot surface
mesh(X,Y,Z)
mesh(X,Y,Z) does not give me the shape I expect. Could it be possible that a problem arises due to how my surface includes planes parallel to the Y-Z plane, thus mapping an x-y coordinate to multiple z values?
Thanks once again for your input.
Regards,
2 commentaires
Yoav Livneh
le 26 Juil 2011
Could it be that you meant 2*pi*spacing in the definition of Th and Phi?
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!