I am currently working on a project which involves translating a program which runs in MATLAB to Python to increase speed and efficiency. However, I have hit a stumbling block. First, I am confused as to what the tilde(~) indicates in MATLAB, and how to represent that in a corresponding way in python. Second, I have been searching through documentation and I'm also having a difficult time finding an equivalent function for the 'sign' function in MATLAB.
indi = ~abs(indexd);
wav = (sum(sum(wv)))/(length(wv)*(length(wv)-1));
thetau = (sign(sign(wv - wav) - 0.1) + 1)/2;
thetad = (sign(sign(wav - wv) - 0.1) + 1)/2;
I have already converted indexd, and wv, which are from a previous section of code, to numpy arrays. What is the most efficient Pythonic way to replace the ~ and sign functions?
NOT
andsign
returns the sign of a numeric value. – Cory Kramer