Append rows to .mat file
Mostra commenti meno recenti
How do I append row(s) of data to an existing array in a .mat file. The following works except the 2nd to last line:
tableIt = [1 2 3;4 5 6;7 8 9];
tableMore = [10 11 12];
filename = 'aTable.mat';
data2store = 'tableIt';
more2store = 'tableMore';
save(filename,data2store');
whos('-file',filename);
m = matfile(filename,'Writable',true);
m.tableIt(end+1,:) = more2store;
whos('-file',filename);
4 Commenti
Walter Roberson
il 9 Nov 2019
save(filename, data2store, '-v7.3');
without the -v7.3, the .mat file would typically default to -v7 and those are not writable.
Brent
il 9 Nov 2019
Walter Roberson
il 9 Nov 2019
It is recommended to not use end in this context. See https://www.mathworks.com/help/matlab/ref/matlab.io.matfile.html
Brent
il 9 Nov 2019
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Environment and Settings 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!