フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Why does this not plot?

1 回表示 (過去 30 日間)
Jacob Savona
Jacob Savona 2015 年 3 月 11 日
閉鎖済み: dpb 2015 年 3 月 12 日
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
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.
Jacob Savona
Jacob Savona 2015 年 3 月 12 日
Never mind it runs fine. But thanks anyway.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by