using surf and pol2cart on matrix

조회 수: 6 (최근 30일)
prrrrr
prrrrr 2020년 6월 25일
댓글: Star Strider 2020년 6월 26일
hello i have a 512x1000 matzrix
the coordinates are there divided into lines (x) as radius and columns (y) as angles. To each point in the matrix belongs a value (z).
How do I get the polar coordinates into cartesian coordinates (pol2cart). And can it plot at the end (with surf?)?
I would like to get in principle from my picture A the picture B
EDIT Forgot Code Example:
angles = (0:pi/8:2*pi)';
radii = 1:10;
[X, Y] = pol2cart(angles, radii)
  댓글 수: 1
Adam Danz
Adam Danz 2020년 6월 25일
Are the angles vector and the radii vector supposed to be different lengths?
How do those values plot a circle?

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

채택된 답변

Star Strider
Star Strider 2020년 6월 25일
편집: Star Strider 2020년 6월 25일
The matrix you have is actually the ‘Z’ matrix. You need to create separate radius and angle matrices of the same size (use ndgrid or meshgrid for that, and be aware that their outputs are not the same), then use all three of those matrices as arguments to pol2cart. You will likely need to experiment a bit.
EDIT — (25 Jun 2020 at 23:17)
Using code example, try something like this:
Z = rand(512,1000); % Create 'Z'
angles = linspace(0, 2*pi, size(Z,2));
radii = linspace(1, 10, size(Z,1));
[A, R] = meshgrid(angles, radii);
[X, Y, Z] = pol2cart(A, R, Z);
figure
surf(X, Y, Z)
shading('interp')
grid on
.
  댓글 수: 2
prrrrr
prrrrr 2020년 6월 26일
편집: prrrrr 2020년 6월 26일
thanks a lot :D
Star Strider
Star Strider 2020년 6월 26일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by