Adding new table data to an existing table (while loop)

I have a 16x1 table (or array) of data that is calculated during each loop iteration. However, I would like to simply add a new 16x1 column to this same table 'A', with the new calculated data in the next column of said table, for N times of the loop. Today, the iteration overwrites the table. What is desired, is if I run the loop 250 times, it would look like a 16x250 table. For example:
i=0;
N=250;
while i < N
//do my 16 variable calculations
//store data in 16xN table/array
i=i+1
end

1 件のコメント

Tim Zoley
Tim Zoley 2015 年 5 月 15 日
To help clarify the type of table I am using, it looks like:
A=[x1;x2;x3....;x16];

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

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 5 月 15 日

1 投票

A(end+1,:) = new vector of 16 values
Note: it is much more efficient to pre-allocate the array and write into the appropriate column.
A = zeros(16, N);
for i = 1 : N
A(:,i) = .....
end

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

質問済み:

2015 年 5 月 15 日

回答済み:

2015 年 5 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by