problem with fzero func
Afficher commentaires plus anciens
I Have problem with this part of code it returns the following error 'Function values at interval endpoints must be finite and real.' in the linen where M(m)=fzero(func,x_int).I have the latest version of matlab
%% Pressione in uscita
if (11000>ALT) && (ALT<25000)
T = -56.46; %C
p_o = 1000*(22.65*exp(1.73-0.000157*ALT));
elseif ALT>=25000
T = -131.21 + 0.00299*ALT ;
p_o = 1000*(2.488*((T+273.1)/216.6)^-11.388);
else
T = 15.04 - 0.00649*ALT;
p_o = 1000*(101.29*((T+273.1)/288.08)^5.256);
end
%% Inizio il calcolo
PR = p_o/p_1;
PR2 = (p_o/p_1)^((g-1)/g);
TT = (2*g*R*T_1)/(g-1);
p_t = ((2/(g+1))^(g/(g-1)))*2.068;
v_t = sqrt((2*g*R*T_1)/(g+1));
v_e = sqrt(TT*(1-PR2));
if m_dot==0
m_dot=FT/v_e;
elseif FT==0
FT = m_dot/v_e;
else
fprintf('You can either set desired thrust OR mass flow rate')
end
T_e = T_1*(p_o/p_1)^((g-1)/g);
a_e = sqrt(g*R*T_e);
Me = v_e/a_e;
% Metodi delle caratteristiche
TR = 35; %raggio della gola in cm
RTOD = 180/pi;
DTOR = pi/180;
P = []; %punti sull' asse delle x
%% Parametrizzazione funzione di Prantl meyer
A = sqrt((g+1)/(g-1));
B = (g-1)/(g+1);
v_PM = @(x) A*atan(sqrt(B*(x^2-1))) - atan(sqrt(x^2-1));
%% Calcolo T_max, BREAK UP INTO DIVISIONS
T_max = 0.5*v_PM(Me)*RTOD;
DT = (90-T_max) - fix(90-T_max);
T(1) = DT*DTOR;
n = T_max*2;
for m = 2:T_max*2
T(m) = (DT + (m-1))*DTOR;
%Mach from T(i) using T(i) = v_PM (FALSE POSITION)
x_int = [1 1.01*Me];
func = @(x) T(m) - v_PM(x);
M(m) = fzero(func,x_int);
P(m) = 0 + TR*tan(T(m)); %X-AXIS POINTS
%RRSLOPES
RR(m) = -TR/P(m);
%LR slopes
LR(m) = tan(T(m)+asin(1/M(m)));
SL(m) = -RR(m);
end
2 commentaires
Matt J
le 8 Jan 2021
For which m in the loop does this occur? Also, have you checked that func(x_int(1)) and func(x_int(2)) are both finite and real, as the error message suggests?
Mathieu NOE
le 8 Jan 2021
hello Francesco
would be glad to help , but we miss a bunch of initialisation of data to run this code
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!