I used different codes to plot the phase of this function f(z) = (0.10 + 0.3i) + (0.4243 + 0.0017i)z + (0.9 − 0.001i)z^2 why I always find discontinuity at Z_R =0
4 views (last 30 days)
Show older comments
This question was flagged by Cris LaPierre
I used the folloing 2 codes from Davidgoodman and Torsten (Thank you very much for all of them) respectivally to plot this function
f(z) = (0.10 + 0.3i) + (0.4243 + 0.0017i)z + (0.9 − 0.001i)z^2
My question IS:
why always find dis continuity at Z_R (the real part of Z) in the phase of this function? and how to avoid this discontinuity?
this are the both codes
This code by Davidgoodman (Thank you very much)
re_z = -1:0.01:1;
im_z = -1:0.01:1;
[re_z,im_z] = meshgrid(re_z,im_z);
z = re_z + 1i*im_z;
caxis([-pi pi])
xlabel('x')
ylabel('y')
p=[(0.9-0.001i) (0.4243 + 0.0017i) (0.10 + 0.3i)];
f_of_z_result = polyval(p,z);
p1=[(0.9 + 0.001i) (0.2121 - 0.0008i) (0.10 -0.3i)];
f_of_1_over_z_result = polyval(p1,1./z);
figure();
subplot(2,2,1)
surf(re_z,im_z,abs(f_of_z_result),'EdgeColor','none')
title('|f(z)|')
xlabel('Z_R')
ylabel('Z_I')
% Zlabel('|f(z)|')
grid on
subplot(2,2,2)
surf(re_z,im_z,angle(f_of_z_result),'EdgeColor','none')
title('phase of f(z)')
xlabel('Z_R')
ylabel('Z_I')
subplot(2,2,3)
surf(re_z,im_z,abs(f_of_1_over_z_result),'EdgeColor','none')
title('|f(1/z)|')
xlabel('Z_R')
ylabel('Z_I')
subplot(2,2,4)
surf(re_z,im_z,angle(f_of_1_over_z_result),'EdgeColor','none')
title('phase of f(1/z)')
xlabel('Z_R')
ylabel('Z_I')
% Zlabel('phase of f(z)')
grid on

This code by Torsten (Thank you very much)
f = @(x,y) (0.3162).*exp(1i*((0.398)*pi))+((x+1i*y).*(0.4243).*exp(1i*((0.0013)*pi)) + (x+1i*y).^2*(0.9).*exp(-1i*(0.00035)*pi));
r = 0:0.01:0.9;
phi = 0:0.01:2*pi;
[R,PHI] = meshgrid(r,phi);
X = R.*cos(PHI);
Y = R.*sin(PHI);
F=f(X,Y);
figure
subplot(2,2,1)
surf(X,Y,abs(f(X,Y)),'EdgeColor','none')
view(2)
colorbar
title('|f(z)|')
xlabel('Z_R')
ylabel('Z_I')
% Zlabel('|f(z)|')
grid on
subplot(2,2,2)
surf(X,Y,angle(f(X,Y)),'EdgeColor','none')
view(2)
colorbar
title('phase of f(z)')
xlabel('Z_R')
ylabel('Z_I')
% Zlabel('|f(z)|')
grid on
subplot(2,2,3)
surf(X,Y,angle(f(X,Y)),'EdgeColor','none')
view(2)
colorbar
title('phase of f(z),view(2)')
xlabel('Z_R')
ylabel('Z_I')
% Zlabel('|f(z)|')
grid on

As we can see both codes work with |f(z)|, but not with the phase of the function.
I appriciate any help.
2 Comments
Jeffrey Clark
on 7 Aug 2022
@Aisha Mohamed, when looking at phase (angle) over some extent of a function it is visually easier to see relationships when unwrap is used to make it linear continuous: Shift phase angles - MATLAB unwrap (mathworks.com)

Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!