Adding new table data to an existing table (while loop)
Mostra commenti meno recenti
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 Commento
Tim Zoley
il 15 Mag 2015
Risposte (1)
Walter Roberson
il 15 Mag 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
Categorie
Scopri di più su Tables in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!