There are many errors I cannot spot in this script. Can someone help please
Afficher commentaires plus anciens
This is what I am working with and I absolutely cannot get it to work.
function [r,theta,phi] = EGA118_M2_Q3s (x,y,z)
%%
%% This function returns the spherical polar coordinates (r, theta, phi)
%% that correspond to the input Cartesian coordinates (x, y, z).
%% theta (azimuthal angle) and phi (polar angle) are expressed in degrees.
if nargin == 0
r = 0;
theta = atan2(y,x);
phi = 0;
elseif nargin == 1
r = x;
theta = atan2(y,x);
phi = 0;
elseif nargin == 2
r = sqrt(x^2+y^2);
theta = atan2(y,x);
phi = 0;
else
r = sqrt(x^2+y^2);
theta = atan2d(y,x);
phi = atan2(z,r);
end
end
1 commentaire
BobH
le 11 Mar 2020
When nargin is 0, x and y are not provided, so what values are being used in the atan2?
Similarly for nargin of 1, what value is being used for y in the atan2?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Lengths and Angles dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!