I want to convert from Cartesian to spherical coordinates in MATLAB. I have tried to use cart2sph in MATLAB but it is showing some error
조회 수: 9 (최근 30일)
이전 댓글 표시
My MATLAB Code is as follows :
function [phi,theta] = calc_phitheta_geom(xyz_source,xyz_mic1,xyz_mic2)
mid_p =(xyz_mic1 + xyz_mic2)/2 %midpoint calculation of xyz_mic1 and xyz_mic2
V = mid_p - xyz_source %Vector from midpoint till xyz_source
[phi,theta] = cart2sph(V) %converting Vector V from cartesian to spherical
end
Now actually Matlab command requires parameter for cart2sph as follows:
[phi,theta] = cart2sph(x,y,z) % here x y z are cartesian coordinates.
My question is that when I am using [phi,theta] = cart2sph(V) it is showing not enough input arguments.
How can I resolve this issue? Can anybody help me in this regard?
Thank you.
댓글 수: 0
채택된 답변
Ahmet Cecen
2018년 3월 18일
You have to actually input the x, y and z vectors separately.Like
[azimuth,elevation,r] = cart2sph(V(:,1),V(:,2),V(:,3));
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!