How can I plot this function such as all values of |f(1/z)| be more clear and how can I plot the cosine of the phase of this function ?

When I plot this function (thanks for every help).
f(1/z) = (0.1000 -0.3000i)z^-1 + (0.2121-0.0008i)z^-2 + (-0.9000-0.0010i)z^-3
I want to study time evolution of this functions, but I have got from its figure that:
1-the |f(1/z)| seems to take zero every where exept at z=o when it goes to infiniy, even when I tried to change the values of z , I always get the same graph
My questions are:
1:How can I plot this figure such that all values of z in the plane appeare more clear to enable me to study its movement over time?
2- How can I plot the cos for the phase of f(1/z) to get more cleare plotting of the phase of this function?
p1=[(0.9000+0.0010i) (0.2121-0.0008i) (0.1000 -0.3000i)];
This is the figure of |f(1/z)| and the phase of f(1/z)
I used this link:
re_z = -6.005:.01:6.005;
im_z= -6.005:.01:6.005;
[re_z,im_z] = meshgrid(re_z,im_z);
z = re_z + 1i*im_z;
xlabel('x')
ylabel('y')
f_of_1_over_z_result = polyval(p1,1./z);
figure();
subplot(2,2,3)
surf(re_z,im_z,abs(f_of_1_over_z_result),'EdgeColor','none')
colorbar
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')
colorbar
title('phase of f(1/z)')
xlabel('Z_R')
ylabel('Z_I')
grid on
I appriciate any help.

 Accepted Answer

It looks like the nearly infinite value in your data is drowning out the remaining data. You can fix this by changing the z-limits and color limits, using the zlim and caxis commands.
For example:
% Prepare the data for plotting
p1=[(0.9000+0.0010i) (0.2121-0.0008i) (0.1000 -0.3000i)];
re_z = -6.005:.01:6.005;
im_z= -6.005:.01:6.005;
[re_z,im_z] = meshgrid(re_z,im_z);
z = re_z + 1i*im_z;
f_of_1_over_z_result = polyval(p1,1./z);
% Create first picture
nexttile
surf(re_z,im_z,abs(f_of_1_over_z_result),'EdgeColor','none')
colorbar
title('|f(1/z)|')
xlabel('Z_R')
ylabel('Z_I')
zlim([0 4]) % Adjust this value as needed
caxis([0 4]) % Adjust this value as needed
%%
nexttile
surf(re_z,im_z,angle(f_of_1_over_z_result),'EdgeColor','none')
colorbar
title('phase of f(1/z)')
xlabel('Z_R')
ylabel('Z_I')
grid on

9 Comments

Thanks Benjamin
I am trying to apply your link to study this figure but the program does nor run and I got this message:
Undefined function or variable 'nexttile'.
The command was introduced in R2019b.
My guess is you have an earlier version.
nexttile is a new version of subplot.
If you don't have nexttile you can just replace those two lines with calls to subplot like in your origial code.
Thanks, Benjamin and Torsten very much, now I can limit the value of z and study the magnitude of the function. But I can not study the phase of the function because it seems unclear and does not give correct information about the function even when I limited the value of z.
My question is :
How can I plot the phase of this function to be clear? how can I plot the cosine of the phase instead?
I appreciate any help
Hi Dear
Why in this question f(1/z) = (0.1000 -0.3000i)z^-1 + (0.2121-0.0008i)z^-2 + (-0.9000-0.0010i)z^-3
the polynomial f(1/z) is written by a Matlab expert here without adding (0 ) as the last term in this function,
p1=[(0.9000+0.0010i) (0.2121-0.0008i) (0.1000 -0.3000i)]; but we have got from some Matlab experts answers that this function must write in this form:
p1=[(0.9000+0.0010i) (0.2121-0.0008i) (0.1000 -0.3000i) (0)];
Does that mean both answers are correct, or did we only forget to add 0 at the end of this function?
I appriciate any help
I suggest you test it for a simpler polynomial:
z = 2;
p1 = [1, 2, 3, 0];
polyval(p1,1/z)
ans = 2.1250
(1/z)^3 + 2*(1/z)^2 + 3*(1/z)
ans = 2.1250
p2 = [1, 2, 3];
polyval(p2,1/z)
ans = 4.2500
(1/z)^2 + 2*(1/z) + 3
ans = 4.2500
So the version with the 0 as last element of the vector is the correct one.
To expand on @Torsten's answer: The doc page for polyval explains the input to polyval:
In the first case (without the 0) you have three elements in your vector, which defines a quadratic polynomial (n==2) and the polynomial becomes:
In the second case (with the 0) you have four elements in your vector, which defines a cubic polynomial (n==3) and the polynomial becomes:
Because equals 0, that reduces to
But, you can clearly see the first element of the vector is treated significantly differently with and without the zero.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance 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!