Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Why does this not plot?

2 vues (au cours des 30 derniers jours)
Jacob Savona
Jacob Savona le 11 Mar 2015
Clôturé : dpb le 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 commentaires
dpb
dpb le 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 le 12 Mar 2015
Never mind it runs fine. But thanks anyway.

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by