Effacer les filtres
Effacer les filtres

How change 3D plot shape?

1 vue (au cours des 30 derniers jours)
ali alizadeh
ali alizadeh le 9 Sep 2021
Commenté : ali alizadeh le 9 Sep 2021
Hi
I have a 3D shape that was previously designed with the help of one of the users of this site.
The code is as follows:
data=load('5.csv');
x=data(:,2);
y=data(:,1); y=y/max(y);
a=3*max(abs(x));
[Xq,Zq]=ndgrid(linspace(-a,a,2000));
[~,Rq]=cart2pol(Xq,Zq);
Yq=interp1(x,y,Rq); %rotated about Y-axis
surf(Xq,Yq,Zq,'EdgeColor','none','FaceAlpha',0.6)
xlabel 'X', ylabel 'Y', zlabel 'Z'
and result somting like this:
I'm new and I do'nt know exactly how to change this 3D plot like the one below:
Please help me done this.
Thanks

Réponse acceptée

Dave B
Dave B le 9 Sep 2021
The mesh function is good for this in general.
Getting the camera angle just right can be tricky, sometimes you can get there with the 3d rotating interactive tool.
I also filled in some zeros where you had nan's so that it makes that rectangular shape, and changed the colormap to jet (you might like turbo better but this more closely matched your image).
It's not exact, but pretty close! Note it'll look better in your desktop version than in the browser MATLAB: and you can raise the number of values in the call to ndgrid, 80-100 looked good on my screen.
data=load('5.csv');
x=data(:,2);
y=data(:,1); y=y/max(y);
a=max(abs(x));
[Xq,Zq]=ndgrid(linspace(-a,a,50));
[~,Rq]=cart2pol(Xq,Zq);
Yq=interp1(x,y,Rq); %rotated about Y-axis
Yq(isnan(Yq)) = 0;
mesh(Xq,Yq,Zq,Yq)
set(gca,'DataAspectRatio',[.001 1 .001])
xlabel 'X', ylabel 'Y', zlabel 'Z'
set(gca,'CameraPosition',[.05 40 .05],'CameraViewAngle',20,'CameraUpVector',[.0001 1 .0001])
colormap jet
axis off
Exported Image from MATLAB desktop version:
  1 commentaire
ali alizadeh
ali alizadeh le 9 Sep 2021
Thank you mr Dave B

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Colormaps 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!

Translated by