issue with fzero and root finding
조회 수: 7 (최근 30일)
이전 댓글 표시
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
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!