how to save all output of a loop in a matrix. the loop run throug 200 files dataset and return column vector of 800 points each iteration , i need to have 200x800 matrix as result

 採用された回答

length_of_data = 800; % length of your data
random_data_vector = rand(1,800); % dummy/test data --> update from your file
number_of_files = 200; % number of datasets
% preallocate memory to save. Size = 200 x 800
save_data_mat = NaN(number_of_files,length_of_data);
% loop over your datasets
for iter = 1 : number_of_files
% for each data set, save the vector of data
save_data_mat(iter,:) = random_data_vector;
end
disp(size(save_data_mat))

2 件のコメント

ihab
ihab 2019 年 2 月 27 日
thanks
ihab
ihab 2019 年 2 月 27 日
ok what to do if the loop doesn't return 800 exactly? sometimes 850 and sometimes 750

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索

質問済み:

2019 年 1 月 7 日

コメント済み:

2019 年 2 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by