issue with fzero and root finding
Show older comments
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)
Answers (1)
Matt J
on 3 Oct 2017
You have a typo in your function
vstar = fzero(@(tstar), ...)
Categories
Find more on Power and Energy Systems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!