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

Stephen23
Stephen23 2017년 6월 26일
편집: Stephen23 2017년 6월 26일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Gennaro Arguzzi
Gennaro Arguzzi 2017년 6월 26일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

태그

질문:

2017년 6월 26일

편집:

2017년 6월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by