non-linear equation fzero error
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am having this error while solving. I don't know how to fix it. can someone help me?
% Given parameters
d_T = 0.0001; % diameter of thermocouple wire (m)
L_T = 4; % length of thermocouple wire (m)
d_TP = 0.0005; % diameter of thermocouple junction probe (m)
e = 0.20; % emissivity of thermocouple
k = 30; % heat conduction of thermocouple (W/mK)
T_env = 25 + 273.15; % temperature of environment (K)
T_fg = 1190 + 273.15; % temperature of flue gas (K)
T_wall = 400 + 273.15; % temperature of wall (K)
A = 8; % heat transfer coefficient of flue gas (W/(m^2K))
sigma = 5.67e-8; % Stefan-Boltzmann constant (W/(m^2K^4))
% Surface area of thermocouple junction
A_surf = pi * (d_TP/2)^2;
% Equilibrium equation for temperature of thermocouple junction
fun = @(T_tc) A*(T_fg - T_wall) - sigma*e*A_surf*(T_tc^4 - T_env^4) ...
- (L_T/d_T)*k*A_surf*(T_tc - T_wall);
% Solve for temperature of thermocouple junction
T_tc = fzero(fun, [0 T_fg]);
% Display result in Celsius
T_tc_C = T_tc - 273.15;
disp(['Temperature of thermocouple junction: ', num2str(T_tc_C), ' C']);
1 Kommentar
Dyuman Joshi
am 10 Mai 2023
Bearbeitet: Dyuman Joshi
am 10 Mai 2023
As the error states, the initial values must have opposite signs, as fzero arrives at a solution iteratively via a combination of methods. (@John D'Errico gave a detailed explaination of the working of fzero in one of their answer, I'll add the link to it if I find it)
From the documentation - Initial values to fzero() - "2-element vector — fzero checks that fun(x0(1)) and fun(x0(2)) have opposite signs, and errors if they do not. It then iteratively shrinks the interval where fun changes sign to reach a solution. An interval x0 must be finite; it cannot contain ±Inf."
Moreover, the function in the given range doesn't cross the x-axis (see figure below) and doesn't have a solution.
% Given parameters
d_T = 0.0001; % diameter of thermocouple wire (m)
L_T = 4; % length of thermocouple wire (m)
d_TP = 0.0005; % diameter of thermocouple junction probe (m)
e = 0.20; % emissivity of thermocouple
k = 30; % heat conduction of thermocouple (W/mK)
T_env = 25 + 273.15; % temperature of environment (K)
T_fg = 1190 + 273.15; % temperature of flue gas (K)
T_wall = 400 + 273.15; % temperature of wall (K)
A = 8; % heat transfer coefficient of flue gas (W/(m^2K))
sigma = 5.67e-8; % Stefan-Boltzmann constant (W/(m^2K^4))
% Surface area of thermocouple junction
A_surf = pi * (d_TP/2)^2;
% Equilibrium equation for temperature of thermocouple junction
fun = @(T_tc) A.*(T_fg - T_wall) - sigma.*e.*A_surf.*(T_tc.^4 - T_env.^4) ...
- (L_T./d_T)*k.*A_surf.*(T_tc - T_wall);
fplot(fun,[0 T_fg])
The nearest solution to T_fg is
sol = fzero(fun, T_fg)
% Solve for temperature of thermocouple junction
T_tc = fzero(fun, [0 T_fg]);
% Display result in Celsius
T_tc_C = T_tc - 273.15;
disp(['Temperature of thermocouple junction: ', num2str(T_tc_C), ' C']);
Antworten (0)
Siehe auch
Kategorien
Mehr zu Optimization finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!