Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Why does this not plot?

1 view (last 30 days)
Jacob Savona
Jacob Savona on 11 Mar 2015
Closed: dpb on 12 Mar 2015
It runs through the loop and ends, but it doesn't plot.
function [t]=HW7_JAS_1(P,k,C)
t_lower=0;%lower guess
t_upper=100;%upper guess
t_error=abs(1-((t_upper)/(t_lower)));%error
it=1;%iteration
while t_error >= .0005
t_mid=(t_lower+t_upper)/2;%calculates root
t_error=abs(1-((t_upper)/(t_lower)));%calculates new error
lower_b=(C*exp(k*t_lower))-P;%f(lower bound)
upper_b=(C*exp(k*t_upper))-P;%f(upper bound)
froot=(C*exp(k*t_mid))-P;%f(root)
if lower_b * froot<0%checks if root is in the lower interval
t_upper=t_mid;%if it is switches upper guess to root
elseif upper_b * froot <0%checks if root is in the upper interval
t_lower=t_mid;%if it is switches lower guess to root
elseif lower_b * froot ==0%checks if the lower bound*root=0
t=t_mid;%if is then the that is the root
else
t_lower=t_lower-t_upper;
t_upper=t_upper*2;
end
plot(it,t_mid,'g*')
hold on%allows each point to plotted
xlabel('Iterations')
ylabel('Estimated time values')
legend('Bisection Method')
it=it+1;%new iteration count
end
Thanks for any help
  2 Comments
dpb
dpb on 12 Mar 2015
Don't see why it shouldn't give a scatter plot if it points; unfortunately we have no data so can't run it to see what happens locally.
Jacob Savona
Jacob Savona on 12 Mar 2015
Never mind it runs fine. But thanks anyway.

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!