save('-append') does not work ; what am i doing wrong?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I load in a .mat file into my script which contains a structure array of various variables - one of them the name of some images - the names of the images are pic1, pic2 etc. So the variable is PictureName and then there are rows pictures numbered 1:n
if pic1 and pic2 are already in the .mat file, but I run through my code and want to add pic3 and pic4 to the same .mat file that works fine
But if i start off with pic3 and pic4, and then try and add pic1 and pic2 in a next run through of the code - it overwrites pic3 and pic4 , and i'm just left pic1 and pic2!!
doing save('myfilename.mat', 'myStructuredArrayName') or save('my filename.mat', 'myStructuredArrayName', '-append') doesn't make any difference
what can i do?
thanks
4 commentaires
Adam
le 28 Nov 2016
Modifié(e) : Adam
le 28 Nov 2016
Actually, I didn't pick up fully on all the details of the question before. What you see is the expected and documented behaviour of append. The append option adds new variables to an existing mat file in addition to those already there, but if a variable already exists it will overwrite that variable, it doesn't append within a single variable.
So the 'read it in, concatenate and write it out again' approach is what is needed here if you are sure you want everything saved within the same variable in your mat file.
Réponses (0)
Voir également
Catégories
En savoir plus sur Workspace Variables and MAT Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!