Save string in structure
    11 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hi everyone. I'm trying to save string in a structure, but MATLAB shows me an error.
for i=1:3
  file=strcat('Documento',num2str(i),' - by Gennaro');
  struttura.nome(i)=file;
end
How can I do it?
Thank you very much.
1 Commento
  Stephen23
      
      
 il 26 Giu 2017
				
      Modificato: Stephen23
      
      
 il 26 Giu 2017
  
			struttura.nome(i)
allcoates to one element of an array (the field nome). Presumably the strings has multiple elements, in which case this allocation will be an error. If you want to allocate a non-scalar char array (string) then you will need to use the correct indexing (e.g. using colon), or allocate by redefining that field entirely.
Risposte (1)
Vedere anche
Categorie
				Scopri di più su Structures in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

