save data to a new row in a table for each iteration of a for loop

19 ビュー (過去 30 日間)
Daniel Knight
Daniel Knight 2020 年 2 月 8 日
回答済み: Stijn Haenen 2020 年 2 月 8 日
Table is pre-alocated at begining of script outside of loop, each loop produces new variables. currently only saves the last iteration of the loop. Have tried data assignment both in and outside of for loop.
% starting variable list
sz = [3000 4];
vartype = {'double','double','double','double'};
varnames = {'Range','Height','Drift','Time_of_Flgiht'};
data1 = table('Size',sz,'VariableTypes',vartype,'VariableNames',varnames);
for T = 0:0.1:20
% some equations
data1(:,1) = {variable1};
data1(:,2) = {variable2};
data1(:,3) = {variable3};
data1(:,4) = {variable4};
end

採用された回答

Stijn Haenen
Stijn Haenen 2020 年 2 月 8 日
something like this might be useful for you:
data=[];
for i=1:0.1:10
data(:,end+1)=[i^2;i^3];%just example of data
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by