I plot these two functions by Matlab but the phase of the both of them look likes strange and I think the plot of the phase is wrong in both of them
1 view (last 30 days)
Show older comments
I plot these two functions by Matlab but the phase of the both of them look likes strange and I think the plot of the phase is wrong in both of them can you help me to correct these figures
the first function is f(z) = (0.10 + 0.3i) + (0.4243 + 0.0017i)*z + (0.9 − 0.001i)*z^2 and its plot is
the phase of this function look likes rwrong because for example at Z_R equales zero Z_I increace sharply and I do not know the correct value of Z_I ?
The second function is
f(z) = (0.10 − 0.3i)*z^(−1) + (0.2121 − 0.0008i)*z^(−2) + (0.9 + 0.001i)*z(−3).
and its figure is
Also here the phase of the function looks like wrong because for examble at Z_R equales zero Z_I increace sharply and I do not know the correct value of Z_I ?
I appreciate any help
2 Comments
Jeffrey Clark
on 27 May 2022
Phase discontinuity indicates you probably have to unwrap the phase; see Shift phase angles - MATLAB unwrap (mathworks.com). This is commonly done when looking at the phase following FFT.
Answers (1)
SAI SRUJAN
on 31 Jan 2024
Hi Aisha,
I understand that you are facing an issue while plotting the phase of a complex function.
When plotting the phase of a complex function, it's important to ensure that the phase is continuous over the region of interest. MATLAB's 'angle' function returns values between '-pi' and 'pi', resulting in discontinuities when the phase crosses these boundaries.
The 'unwrap' function in MATLAB is used to correct the phase angles to produce smoother phase plots. This function is particularly useful when you want to visualize the phase as a continuous function over a range of input values.
Please refer to the following example to proceed further,
[X, Y] = meshgrid(linspace(-1, 1, 100), linspace(-1, 1, 100));
Z = X + 1i*Y;
fz = (0.10 + 0.3i) + (0.4243 + 0.0017i)*Z + (0.9 - 0.001i)*Z.^2;
phase_fz = unwrap(angle(fz), [], 2);
figure;
surf(X, Y, phase_fz, 'EdgeColor', 'none');
colorbar;
By unwrapping the phase, the plot should show a smooth transition of phase angles, without the artificial jumps caused by the branch cuts of the 'angle' function. Please refer to the following documentation for a better understanding of the 'unwrap' MATLAB function.
I hope this helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!