How change 3D plot shape?

2 次查看(过去 30 天)
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

采纳的回答

Dave B
Dave B 2021-9-9
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:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by