calculating the root of a complex number
Show older comments
Hello, I have encountered a problem with the conversion of certain experimental measurements while programming in Matlab. The Task is to calculate the acoustic absorption degree in a range of 0 to 2000 Hz. The mistake happens when I am trying to solve the complex root of a (1,401)vector. It calculates one of the two possible answers but uses wrong solutions for other certain parts. Is it the Matlab problem when the angle is being displayed negative? I used atan2 but it does not help.
1) The faulty code:
H12=sqrt((Z1.*Z2)); %z1 and 2 being the (1,401)vectors
2) My detour:
angle1= atan2(imag(Z1),real(Z2));
angle2= atan2(imag(Z2),real(Z2));
Z1=(abs(Z1).*exp(1i*angle1));
Z2=(abs(Z2).*exp(1i*angle2));
H12=sqrt((Z1.*Z2));
->same output
Its a conversion of some parts of H12 into its negative counterpart -H12 but I cannot identify the pattern.
I am including a picture of what the faulty plot looks like (plot above) and what it should look like(right under it). The plot is correct for the part between x=400:880 Hz

Thanks in advance
1 Comment
Andrew Newell
on 10 Mar 2015
This is difficult to answer without knowing more about the calculation. Maybe there is some requirement such as the real part should be positive. If so, you could try simply multiplying the square root by the sign of the real part.
Accepted Answer
More Answers (0)
Categories
Find more on Elementary Math in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!