Append rows to .mat file
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Brent
el 9 de Nov. de 2019
Comentada: Walter Roberson
el 9 de Nov. de 2019
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 comentarios
Walter Roberson
el 9 de Nov. de 2019
It is recommended to not use end in this context. See https://www.mathworks.com/help/matlab/ref/matlab.io.matfile.html
Respuesta aceptada
Walter Roberson
el 9 de Nov. de 2019
more2store = 'tableMore';
That is a 1 x 9 character vector.
tableIt = [1 2 3;4 5 6;7 8 9];
That is a 3 x 3 double.
m.tableIt(end+1,:) = more2store;
That attempts to store the 1 x 9 character vector into 3 columns of a double. That does not fit.
4 comentarios
Walter Roberson
el 9 de Nov. de 2019
If you had done
more2store = tableMore;
then it would have worked.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!