Where is the wrong in this code??
Show older comments
Because I trust the answers of all the Matlab experts in this group, and I thank all of them. The genius expert Torsten saw that there is some mistake in my code that used to plot cos(phase(f_b(1/z)), I used his notes but still there are some missing points in this work. I think this is because I did not write my question in the correct way.
So I ask again where is the wrong in this code??
I have two functions f_k(z) and f_b(1/z) where,
1-f_k(z) = (0.1000 + 0.3000i) + (0.4243 + 0.0017i)z + (0.9000- 0.0010i)z^2
we define p from f_k(z)as,
p=[ ( 0.9000 - 0.0010i) (0.4243 + 0.0017i) (0.1000 + 0.3000i) ];
2-f_b(1/z) = (0.1000 - 0.3000i)z^-1 + (0.2121 - 0.0008i)z^-2 + (0.9000 +0.0010i)z^-3
we define p1 from f_b(1/z)as,
p1=[ ( 0.9000 + 0.0010i) (0.2121 - 0.0008i) (0.1000 - 0.3000i) (0)];
The function f_b(1/z) is not defined at z = 0 which means the graph of this function must be undefined at z = 0
But when I use the code %f_of_1_over_z_result = polyval(p1, z); I found the graph for | f_b(1/z) | and | f_k (z) | are same
and | f_b(1/z) | defined at z = 0 (which must not happen in the myfunction |f_b(1/z)| because it is not defined at z = 0) , as you can see from the following figure:

But,
% Where as when I use the code % f_of_1_over_z_result = polyval(p1,1./z);
% the function |f_b(1/z)|does not define at z=0 (that what must happen in my case) as you can see in the following figure,

I used this code,
p=[ ( 0.9000 - 0.0010i) (0.4243 + 0.0017i) (0.1000 + 0.3000i) ];
p1=[ ( 0.9000 + 0.0010i) (0.2121 - 0.0008i) (0.1000 - 0.3000i) (0)];
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_z_result = polyval(p,z);
% %
f_of_1_over_z_result = polyval(p1,1./z); % I used this code in the first figure
% f_of_1_over_z_result = polyval(p1,z); % I used this code in the second figure
figure();
subplot(2,2,1)
surf(re_z,im_z,abs(f_of_z_result),'EdgeColor','none')
colorbar
title('|f_k(z)|')
xlabel('Z_R')
ylabel('Z_I')
zlim([0 15]) %adjust this value as needed
caxis([-6 6]) %adjust this value as needed
% grid on
subplot(2,2,2)
surf(re_z,im_z,cos(angle(f_of_z_result)),'EdgeColor','none')
colorbar
title('cos(phase of f_k(z))')
xlabel('Z_R')
ylabel('Z_I')
zlim([-5 5]) %adjust this value as needed
caxis([-1 1]) %adjust this value as needed
subplot(2,2,3)
surf(re_z,im_z,abs(f_of_1_over_z_result),'EdgeColor','none')
colorbar
title('|f_b(1/z)|')
xlabel('Z_R')
ylabel('Z_I')
zlim([0 15]) %adjust this value as needed
caxis([-0.15 0.15])
subplot(2,2,4)
surf(re_z,im_z, cos(angle(f_of_1_over_z_result)),'EdgeColor','none')
colorbar
title(('cos(phase of f_b(1/z))'))
xlabel('Z_R')
ylabel('Z_I')
caxis([-1 1]) %adjust this value as needed
zlim([-1 1]) %adjust this value as needed
grid on
Where is the wrong in this code??
Accepted Answer
More Answers (0)
Categories
Find more on Subplots 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!