issue with fzero and root finding
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am writing a function that computes the time that the rocket reaches some velocity. I am solving in using fzero. For my initial guess, I used 0. I know the domain for ln is 0, and infinity. I cannot make the domain until infinity, because the second bound needs to be finite. Do I need a second bound? I thought I could just have o, but I am not getting the correct output. Thank you.
% function tstar = fzero_rocket_example(u, g, q, m0, vstar)
%%Input
% m0: initial mass of rocket at time t=0
% g: gravitational constant
% q: fuel consumption rate
% u: velocity at which fuel expelled relative to rocket
% vstar: upward velocity value for which tstar is to be determined
%
%%Output
% tstar: the time that the rocket reaches the specified velocity, vstar. (scalar)
%%Write your code here.
%Compute time that the rocket reaches this velocity
tstar = 0; % Initial Guess
% fzero(function, x0) - used to designe the find the real root of a single equation
% function = name of function being evaluated
% x0 = initial guess
vstar = fzero(@(vstar)u*log(m0/(m0-q*tstar))-g*tstar,0)
0 comentarios
Respuestas (1)
Matt J
el 3 de Oct. de 2017
You have a typo in your function
vstar = fzero(@(tstar), ...)
0 comentarios
Ver también
Categorías
Más información sobre Problem-Based Optimization Setup 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!