Save Struct as .mat file!!!
    9 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    M G
      
 el 11 de Ag. de 2013
  
    
    
    
    
    Comentada: Walter Roberson
      
      
 el 14 de En. de 2021
            Hello all,
I have a problem in saving Struct format in .mat file.
If I have "a" as 1x5 struct
So, in command window it looks like this:
a = 
ans =
     246
ans =
     444
ans =
     630
ans =
     810
ans =
     984
Any way that I can save it as a .mat file of 1x5?
Thanks so much for your help :)
Respuesta aceptada
  Jan
      
      
 el 12 de Ag. de 2013
        Of course this does not work, because "a.latency" is not a name of a variable. You need:
save('filename.mat', 'a')
The functional form is less confusing for the save command.
If you want to save the fields "latency" only:
latency = {a.latency};
save('filename.mat', 'latency')
11 comentarios
  Gustavo Araujo
 el 13 de En. de 2021
				Is there a way to save those mat files sequentially? I mean: create a loop saving File1.mat, File2.mat and so on. I'm trying:
for i=1:3
  Ir(i) = [Ir];
end
save('Irn.mat', 'Ir');
but the Irn saves in another column the second and third variable. How to proceed correctly? 
Thank you in advance.
  Walter Roberson
      
      
 el 14 de En. de 2021
				for K = 1 : number_of_files
    filename = sprintf('File%d.mat', K);
    save(filename, 'Ir')
end
Más respuestas (1)
  the cyclist
      
      
 el 11 de Ag. de 2013
        What do you mean by "a .mat file of 1x5"?
>> save filename.mat a
will save the structure, exactly as it is in the workspace.
>> load filename.mat a
will load it back into the workspace.
Ver también
Categorías
				Más información sobre File Operations 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!







