non-linear equation fzero error

조회 수: 4 (최근 30일)
uzzi
uzzi 2023년 5월 10일
편집: Dyuman Joshi 2023년 5월 10일
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]);
Error using fzero
Function values at the interval endpoints must differ in sign.
% Display result in Celsius
T_tc_C = T_tc - 273.15;
disp(['Temperature of thermocouple junction: ', num2str(T_tc_C), ' C']);
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 5월 10일
편집: Dyuman Joshi 2023년 5월 10일
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)
sol = 2.4236e+04
% Solve for temperature of thermocouple junction
T_tc = fzero(fun, [0 T_fg]);
Error using fzero
Function values at the interval endpoints must differ in sign.
% Display result in Celsius
T_tc_C = T_tc - 273.15;
disp(['Temperature of thermocouple junction: ', num2str(T_tc_C), ' C']);

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Optimization에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by