Info
此问题已关闭。 请重新打开它进行编辑或回答。
Why does this not plot?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2015-3-12
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.
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!