How do I create a table of each iteration from my while loop?

9 ビュー (過去 30 日間)
Umut Ayyildiz
Umut Ayyildiz 2019 年 3 月 27 日
回答済み: safi khan 2020 年 1 月 4 日
v0=35.35;
c=13.45;
m=67.5;
g=9.81;
t=4;
%vf=0;
iteraton=0;
while iteraton<8
iteraton=t+iteraton;
vf=v0+(g-c/m*v0)*t;
v0=vf;
end
So this is my code for Euler's method, I would like to create a table of each iteration but don't know how to. Thank you in advance!
  1 件のコメント
Amal George M
Amal George M 2019 年 4 月 1 日
Could you please provide some additional details on the variable or data, to be stored in the table?

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

回答 (3 件)

djedoui Nassim
djedoui Nassim 2019 年 4 月 1 日
Hello
you can do so
v0=35.35;
c=13.45;
m=67.5;
g=9.81;
t=4;
%vf=0;
iteraton=0;
while iteraton<8
iteraton=t+iteraton;
vf=v0+(g-c/m*v0)*t;
v0=vf;
tabl(iteraton)=vf;
end

KSSV
KSSV 2019 年 4 月 1 日
v0=35.35;
c=13.45;
m=67.5;
g=9.81;
t=4;
%vf=0;
iteraton=0;
iter = zeros([],1) ;
Vf = zeros([],1) ;
count = 0 ;
while iteraton<8
count = count+1 ;
iteraton=t+iteraton;
vf=v0+(g-c/m*v0)*t ;
v0=vf ;
iter(count) = iteraton ;
Vf(count) = vf ;
end
iter = iter'; Vf = Vf';
T = table(iter,Vf)

safi khan
safi khan 2020 年 1 月 4 日
Here is the code of "Table 2" on while loop.
a=1;
while a<06;
z=a*2;
disp(z);
a=a+1;
end

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by