Adding new table data to an existing table (while loop)
Show older comments
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 Comment
Tim Zoley
on 15 May 2015
Answers (1)
Walter Roberson
on 15 May 2015
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
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!