Adding new table data to an existing table (while loop)
Ältere Kommentare anzeigen
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 Kommentar
Tim Zoley
am 15 Mai 2015
Antworten (1)
Walter Roberson
am 15 Mai 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
Kategorien
Mehr zu Tables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!