How to solve error message in fsolve stating: "The vector of function values is near zero, as measured by the selected value of the function tolerance. However, the last step was ineffective"

10 views (last 30 days)
Dear all, I am trying to solve transcendental equations of TM mode using fsolve, but I constantly get error message stating:
"The vector of function values is near zero, as measured by the selected value of the function tolerance. However, the last step was ineffective."
Here are the code and myfun fiels, please help me!
Thxs!
% Given:
close all; clear all;
mu_o = 4*pi*10^(-7); mu_r = 1;
esp_o = (10^(-9))/(36*pi); esp_r = 2.56;
esp_d = esp_o*esp_r;
mu_d = mu_o*mu_r;
h = 0.3175; % [cm]
f_c1 = 18.913e9; % from example 8-11 pp 17.
f = 0:f_c1/1000:2*f_c1;
b_z = 0; %Initialization
for f_index = 1:1:length(f)
w = (2*pi*f(f_index));
b_z = 793; % Initial point guessing
options = optimset('Display','iter','MaxFunEvals',1e20,'TolFun',1e-10,'TolX',1e-10);
b_z_sol = fsolve(@myfun, b_z, options);
end
b_yd_sol = (sqrt(w.^2*mu_d*esp_d - b_z_sol.^2))/100; % [rad/cm] equ. 8-160c
a_sol = (sqrt(b_z_sol.^2 - (w.^2*mu_o*esp_o)))/100; % [rad/cm] equ. 8-160d
b_o = w*sqrt(mu_o*esp_o);
b_d = w*sqrt(mu_d*esp_d);
% Figure-a
subplot(2,1,1);
plot(f(f_index)/f_c1,real(b_z_sol));
hold on;
plot(f(f_index)/f_c1, real(b_yd_sol), ':');
plot(f(f_index)/f_c1, real(a_sol), '--');
hold off;
axis([0 f(f_index)/f_c1 0 9]);
xlabel('Normalized frequency (f/f_C_1)');
title('Attenuation and Phase Constants of TM^{Z}_m');
subplot(2,1,2);
% Figure-b
plot(b_o, w);
hold on;
plot(b_d, w);
plot(real(b_z_sol), w);
axis([0 13e2 0 2e11]);
xlabel('\beta_o \beta_z \beta_d');
ylabel('\omega(\beta_o \beta_z \beta_d)');
title('Dispersion Curve');
hold off;
% myfum.m file code:
function F = myfun(b_z)
global w;
mu_o = 4*pi*10^(-7);
mu_r = 1;
esp_o = (10^(-9))/(36*pi);
esp_r = 2.56;
esp_d = esp_o*esp_r;
mu_d = mu_o*mu_r;
h = 0.3175; % [cm]
f_c1 = 18.913e9; % from example 8-11 pp 417
f = 0:18.913e6:2*f_c1;
for f_index = 1:1:length(f)
end
w = (2*pi*f(f_index));
% Iteration equations for the three unknowns
b_yd = (sqrt(w.^2*mu_d*esp_d - b_z.^2))/100; % [rad/cm] equ. 8-160c
a = (sqrt(b_z.^2 - (w.^2*mu_o*esp_o)))/100; % [rad/cm] equ. 8-160d
F = (a*(esp_d/esp_o)) - (b_yd*h*tan(b_yd*h)); % equ 8-160b
end
  2 Comments
madhan ravi
madhan ravi on 22 Nov 2018
Please don’t close the question that have an answer becuase it will be deleted after 10 days if a question is closed.
Kai Wang
Kai Wang on 31 Mar 2020
Hi, I think what you have plotted is a single point. You should let b_o, b_d and w to be a colume vector.

Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 15 Nov 2018
Without running your code, I can tell you that the exit message you give is NOT an error message. Read its first part:
"The vector of function values is near zero, as measured by the selected value of the function tolerance."
This means that fsolve found a solution. So I think that you should't worry about the second part of the message, which is about algorithm internals.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 Comments
Yonas Gezahegn
Yonas Gezahegn on 16 Nov 2018
Edited: Yonas Gezahegn on 16 Nov 2018
Thanks a lot Alan!
My problem is to plot a graph using the output results.
Can anyone can give me a hint please.
Alan Weiss
Alan Weiss on 16 Nov 2018
I don't understand what you want to plot. I suggest that you start a new question with some details.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!