genvarname for string with structure fieldname
조회 수: 9 (최근 30일)
이전 댓글 표시
hi,
I have a string of a variable that includes a structure fieldname, but genvarname does interpret the point '.' wrong:
run = 1;
name = (['DATACUE', num2str(run)]);
>> genvarname([name '.Grid_coord'])
ans =
DATACUE10x2EGrid_coord
what I want is
DATACUE1.Grid_coord
Does anyone know how I can do this?
Many thanks! Nico
댓글 수: 0
답변 (1개)
Fangjun Jiang
2011년 6월 24일
genvarname() is used to create a valid MATLAB variable name, not to create the variable name with a field name together. You can use genvarname() to make sure 'DATACUE1' is a valid variable name first and then assign field nane 'Grid_coord' to it. If you want to make sure there is no conflict among all the field names, you can use the fieldnames() function.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!