필터 지우기
필터 지우기

3D axis rotation with meshgrid

조회 수: 1 (최근 30일)
Laura Mugica
Laura Mugica 2018년 9월 17일
댓글: Laura Mugica 2018년 9월 20일
Hello, I would like to rotate B around the z axis and plot the contour plot. I tried the following but I don't think it is working since the contour plot after the rotation should not be symmetric.
Hope anyone can help,
thet=[0:0.01*pi:pi];
plane=[-15:0.02:15,15:0.02:15];
z = 10;
[theta,plane,z]=meshgrid(thet,plane,z);
[x,y,z]=pol2cart(theta,plane,z);
r = sqrt(x.^2+y.^2+z.^2)*1e-9;
B = const*((300e-18)./r.^5-1./r.^3)*1e6;
phi = 53;
%rotation around Z axis
X = x.*cos(phi) - y.*sin(phi);
Y = x.*sin(phi) + y.*cos(phi);
contourf(x,y,B,25,'LineStyle','none')

답변 (1개)

Naman Chaturvedi
Naman Chaturvedi 2018년 9월 20일
편집: Naman Chaturvedi 2018년 9월 20일
You aren't plotting the updated values X and Y. Last line should be:-
>> contourf(X,Y,B,25,'LineStyle','none')
  댓글 수: 1
Laura Mugica
Laura Mugica 2018년 9월 20일
I get exactly the same plot when I use contourf(X,Y,B,25) that's why I think it's not working.

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by