フィルターのクリア

How do I store values from a for loop into a table?

8 ビュー (過去 30 日間)
Helena
Helena 2018 年 5 月 8 日
回答済み: Peter Perkins 2018 年 5 月 14 日
I am running a loop for i=1:1:41 and each time end up with a column vector which is a time series of prices with a size of 89x1. The loop just wipes over the price column every time the new value i is input.
How do I run the loop so that I store the prices for every value of i so I end up with a matrix of 89x41?
Thanks!

採用された回答

Guillaume
Guillaume 2018 年 5 月 8 日
tables and matrices are two very different things.
yourdesiredmatrix = zeros(89, 41);
for i = 1:41
%calculate something
yourdesiredmatrix(:, i) = your89x1_result
end
  1 件のコメント
Helena
Helena 2018 年 5 月 8 日
Thanks so much!

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

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2018 年 5 月 14 日
Or perhaps
yourdesiredtable = array2table(zeros(89, 41));
for i = 1:41
%calculate something
yourdesiredtable.(i) = your89x1_result
end

カテゴリ

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