i want to plot the graph for while loop but the graph was blank

1 回表示 (過去 30 日間)
Fakrullah eiman Noor
Fakrullah eiman Noor 2023 年 1 月 21 日
編集済み: VBBV 2023 年 1 月 21 日
d=1;
while X>=t
fprintf('Value of T0 at t=%d is %d\n',t,T0);
%compute f(t,T0)
ftT0= f(t,T0);
%compute newTo
newT0= T0+h.*ftT0;
%for printing
rsl(d,:)=[t T0 ftT0 newT0];
%update iteration
d=d+1;
%update t
t= t+h;
%update T0
T0= newT0;
end
plot(t,T0)

回答 (1 件)

VBBV
VBBV 2023 年 1 月 21 日
t(d)= t+h;
%update T0
T0(d)= newT0;
  2 件のコメント
VBBV
VBBV 2023 年 1 月 21 日
To plot a graph, use a vector of values for the variables by indexing them in a loop
VBBV
VBBV 2023 年 1 月 21 日
編集済み: VBBV 2023 年 1 月 21 日
ftT0= f(t(d),T0(d));
%compute newTo
newT0= T0(d)+h.*ftT0;
%for printing
rsl(d,:)=[t(d) T0(d) ftT0 newT0];
%update iteration
d=d+1;
%update t
t(d)= t(d)+h;
%update T0
T0(d)= newT0;

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by