Need help with bisection of this function, any advise or help would be great! thanks in advance to all!
2 views (last 30 days)
Show older comments
this is the code I used for the first part of the question and is correct:
h=0.1;
t=36;
N=(t/h);
t=zeros(1,N+1);
p=zeros(1,N+1);
t(1)=0;
p(1)=87;
for n=1:N
t(n+1)=t(n)+h;
u=sin((2*pi*t)/12);
H=15*[nthroot(u,15)+1]
p1(n+1)=p(n)+h*[(0.016*p(n)*(100-p(n)))-H(n)];
p(n+1)=p(n)+(h/2)*[[(0.016*p(n)*(100-p(n)))-H(n)]+[(0.016*p(n+1)*(100-p(n+1)))-H(n+1)]];
end
What I need to find now is the largest value of H for which the solution for P(t) does not be 0 at t = 36.
I know some of the code :
H=@(t)15*[nthroot(u,15)+1];
upper-limit=100;
lower-limit=1;
mid-point=(upper-limit+lower-limit)/2;
while lower-limit-upper-limit>0
if (?)*(?)<0
upper-limit=mid-point;
else
lower-limit=mid-point;
end
end
if anyone knows how to fill this parts of my code it would be a huge help!! just confused about how to account for H changing and P at the sametime!!
0 Comments
Answers (0)
See Also
Categories
Find more on NaNs 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!