![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733744/image.png)
How change 3D plot shape?
조회 수: 1 (최근 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:
![](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
채택된 답변
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/733744/image.png)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!