How do for loop and stop when code is catch error 1e-6, and please i need to check following code to get "M1" Value
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
for M1=.1:.1:10
e1=0.0045/.00264;
e2=((2+.135*M1^2)/(2.135))^(2.135/(4*.135))*(1/M1)^0.5;
while abs(e1-e2)~= 1e-4
continue
if abs(e1-e2)== 1e-4
break
end
end
end
fprintf('%3u',M1)
0 commentaires
Réponses (1)
dpb
le 12 Juin 2022
e1=0.0045/.00264;
fnF=@(M1)((2+0.135.*M1.^2)./(2.135)).^(2.135./(4*0.135)).*(1./M1).^0.5-e1;
fplot(fnF,[0.1 3])
shows zero crossings around 0.2 and 2
>> fsolve(fnF,0.2)
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
ans =
0.2102
>> fsolve(fnF,2)
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
ans =
2.3012
>> doc fsolve
>>
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!