Rotate Meshgrid 45 Degrees

조회 수: 4 (최근 30일)
Ermin Sehovic
Ermin Sehovic 2016년 5월 2일
댓글: qilin guo 2021년 6월 10일
I want to rotate my meshgrid 45 degrees. How do I do that? I have the following script:
% meshgrid
[x,y] = meshgrid(-50:5:50);
O = zeros(size(x,1)); % z-values to 0
% Plot
figure; mesh(x,y,O);
az = 0; el = 90; view(az, el);
daspect([1 1 1]);

답변 (2개)

Star Strider
Star Strider 2016년 5월 2일
If I understand correctly what you want to do, just set:
az = 45;
  댓글 수: 2
Ermin Sehovic
Ermin Sehovic 2016년 5월 2일
Not exactly. I want to rotate it from a mathematical point of view. Do I need to multiply with a rotation matrix?
Star Strider
Star Strider 2016년 5월 2일
See if the rotate function will do what you want, since it’s likely the easiest.
Otherwise, there are three functions that could do what you want: makehgtform, hggroup, and hgtransform. They create the rotation and translation matrix for you. They’re all related.

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


Jan Orwat
Jan Orwat 2016년 5월 3일
편집: Jan Orwat 2016년 5월 3일
theta = 45;
x2 = x*cosd(theta) - y*sind(theta);
y2 = x*sind(theta) + y*cosd(theta);
  댓글 수: 2
Ermin Sehovic
Ermin Sehovic 2016년 5월 3일
I have tried it, but it doesn't rotate the mesh 45 degrees as you can see on the picture.
qilin guo
qilin guo 2021년 6월 10일
Very good answer!!! It helps me a lot! Thank you very much!

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by