Effacer les filtres
Effacer les filtres

Save string in structure

24 vues (au cours des 30 derniers jours)
Gennaro Arguzzi
Gennaro Arguzzi le 26 Juin 2017
Modifié(e) : Stephen23 le 26 Juin 2017
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 commentaire
Stephen23
Stephen23 le 26 Juin 2017
Modifié(e) : Stephen23 le 26 Juin 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.

Connectez-vous pour commenter.

Réponses (1)

Gennaro Arguzzi
Gennaro Arguzzi le 26 Juin 2017
Ok, I solved problem:
for i=1:3
file=strcat('Documento',num2str(i),' - by Gennaro');
struttura(i).nome=file;
end
Thank you anyway.

Catégories

En savoir plus sur Structures 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!

Translated by