필터 지우기
필터 지우기

Cartesian to polar sorting

조회 수: 2 (최근 30일)
Suhas Deshpande
Suhas Deshpande 2011년 7월 1일
I converted a set of coordinates from Cartesian to polar form
[rho,theta] = cart2pol(x,y);
Next I sorted the polar coordinates
theta_ascend = sort(theta,'ascend');
As in the case of any polar system I will have multiple values of rho for one value of theta. For every value of theta I want to select the maximum value of rho and reject the other values.
for e.g If my values are
theta = 3.14 3.14 3.14 3.13 3.13 3.12 3.12 3.12 . . . rho = 12 15 6 3 5 8 2 11 . . .
I want my output to be theta = 3.14 3.13 3.12 . . . rho = 15 5 11 . . .
Please suggest ?

채택된 답변

Matt Fig
Matt Fig 2011년 7월 1일
As an example:
% First some data to work with:
thet = round(rand(1,10)*3)
r = round(rand(1,10)*30)
% Now match the largest r per unique thet:
M = sortrows([thet.',r.']);
M = M([logical(diff(M(:,1)));true],:)
  댓글 수: 1
Suhas Deshpande
Suhas Deshpande 2011년 7월 1일
For some reason I am not able to convert the sorted polar coordinates to Cartesian
[x,y] = pol2cart(M(:,1),M(:,2))
or
[x,y] = pol2cart(theta,rho)
gives an error
Error: Unexpected MATLAB operator.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by