how to append a mat file
94 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi - I am using the save command to save a variable in my workplace which is two rows and one column worth of data (2 by 1). However, I would like the 'append' command to move one column the right evertime it is run (as not to replace my first column worth of data), however reading the 'save' help file, it only 'appends' if it is ASCI but does not 'append' when it is a .mat file. How do I prevent my data from being overwritten and instead having new data keep being added to the right (this way, I can just load it, and plot all of first row and use the second row as 'labels' (for the legend))...
save(data.mat,datacell,'-append')
0 Kommentare
Antworten (3)
Walter Roberson
am 17 Mär. 2019
You cannot do that with save()
Have a look at https://www.mathworks.com/help/matlab/ref/matfile.html
0 Kommentare
nas illmatic
am 17 Mär. 2019
1 Kommentar
Walter Roberson
am 17 Mär. 2019
Sure. just load the appropriate variable from the mat file , make the change and save with append (which does work for mat files by replacing the specified variables and leaving the rest in place . ) The built in functionality to handle that is matfile() but you can write your own function .
nas illmatic
am 17 Mär. 2019
Bearbeitet: nas illmatic
am 17 Mär. 2019
4 Kommentare
Maxwell Rosen
am 2 Aug. 2021
I think you have to delete that last save() function. Matlab automatically appends your array that you opened m. See the function https://www.mathworks.com/help/matlab/ref/matlab.io.matfile.html in the example Load and Save Parts of Variables
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!