필터 지우기
필터 지우기

How change 3D plot shape?

조회 수: 1 (최근 30일)
ali alizadeh
ali alizadeh 2021년 9월 9일
댓글: ali alizadeh 2021년 9월 9일
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:
  댓글 수: 1
ali alizadeh
ali alizadeh 2021년 9월 9일
Thank you mr Dave B

댓글을 달려면 로그인하십시오.

추가 답변 (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