0
votes

I'm importing in Matlab a matrix in u/v coordinates but I need them in theta/phi coordinates. I found out that there exist the function uv2phitheta and according to the help this function gives in output a 2 row matrix for the theta/phi components and the value of the cell that I need to convert need to be <=1 . https://www.mathworks.com/help/phased/ref/uv2phitheta.html

I want to convert each element of the matrix in theta/phi, therefore to a single element of my matrix, converted I should get a matrix for the theta component and a matrix for the phi component. tried to implement something like this

    for u=1:size(s_H)
        for v=1:size(s_h)
            s_H=uv2phitheta(s_H(u,v));
        end
    end

but it doesn't work giving me these errors

Error using uv2phitheta Expected UV to be an array with all of the values <= 1.

Error in uv2phitheta (line 29) validateattributes(uv,{'double'},{'2d','real','>=',-1,'<=',1},...

The elements of my matrix s_H are not between (-1,1) but are real numbers. I don't know if I should normalize it.

1

1 Answers

0
votes

The function uv2phitheta is designed to transform from coordinates on the positive hemisphere x ≥ 0 with angles theta and equitorial angle phi illustrated below:

uvToThetaPhi

This corresponds to a mapping between u and v and phi or theta of

u = sin(theta) cos(phi)
v = sin(theta) sin(phi)

Therefore, it only makes sense to talk about values of u and v which are between -1, 1, because otherwise something has gone very wrong somewhere, and the resulting theta and phi would be complex.

In fact, the documentation clearly states the requirements on u and v:

-1 ≤ u ≤ 1 
-1 ≤ v ≤ 1
u^2 + v^2 ≤ 1

Your data should match this. If not, something else has probably gone wrong somewhere.