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
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
dpb
el 12 de Jun. de 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 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!