![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733744/image.png)
How change 3D plot shape?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733574/image.jpeg)
I'm new and I do'nt know exactly how to change this 3D plot like the one below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733579/image.jpeg)
Please help me done this.
Thanks
0 Commenti
Risposta accettata
Dave B
il 9 Set 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733744/image.png)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Colormaps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!