How to add a few variables to an existing .mat file into a new row every time the code is run?
    7 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
I have three variables a, b, c for a few test animals(say 10). I want to run the code for each animal separately to get the three variables for that animal and write it to a .mat file or a structure. When I run it for next animal, the variables are overwritten. How can I add a, b, c for the second animal in the next row and so on?
1 commentaire
  Stephen23
      
      
 le 4 Juil 2017
				
      Modifié(e) : Stephen23
      
      
 le 4 Juil 2017
  
			Note that it is not possible in one command to append new data to a variable already saved in a MAT file (the badly named append option should really be named the overwrite or replace option).
The best option would be to assign the data to one/three variables in the loop, and only do the saving once after the loop has finished. This would be simple with any array using indexing, or a non-scalar structure. Easy, efficient, and this is what most experienced users would do.
An alternative would be to write multiple files:
Réponses (0)
Voir également
Catégories
				En savoir plus sur Animation 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!

