Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Why does this not plot?

1 visualización (últimos 30 días)
Jacob Savona
Jacob Savona el 11 de Mzo. de 2015
Cerrada: dpb el 12 de Mzo. de 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 comentarios
dpb
dpb el 12 de Mzo. de 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 el 12 de Mzo. de 2015
Never mind it runs fine. But thanks anyway.

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by