Store output data from a for loop into a matrix?

1 回表示 (過去 30 日間)
Mahmoud
Mahmoud 2015 年 3 月 14 日
編集済み: per isakson 2015 年 3 月 14 日
Hello guys, I'm running this code:
for t =0.02:0.02:0.06
v0=((0.02)/2)*(b+a);
i=i+1;
j=j+1;
a=A(i);
b=A(j);
v1=v0+v1
end
And the results are shown as:
v1 = 2.50
v1 = 7.43
v1 = 0.0001
However I want these results to be stored in a matrix of one column to look like this:
V= [2.5, 7.43, 0.001]
How can I do this?
Thanks in advance

採用された回答

Mahmoud
Mahmoud 2015 年 3 月 14 日
Ok guys I figured it out, I'm just leaving the solution in case someone got the same problem as me:
or t =0.02:0.02:0.06 v0=((0.02)/2)*(b+a); %calculate the velocity using trapezoidal rule between two acceleration values i=i+1; j=j+1; a=A(i); b=A(j); v1=v0+v1; V(k,1)= v1; % k=k+1;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Export to MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by