Dynamic Structure FieldNames in App Designer Properties
이전 댓글 표시
Hello,
I'm new to App Designer. Hoping this great community can help me :)
Aim:
- I want to make a structure which uses dynamic field names available to all call back functions (make it a property) in App Designer
Background:
- The dynamic field names are based on file names that user will import in - Field names could be any string (I do not know)
Supporting image:

Question: How do I make all structure with dynamic field names available as a property please?
Thanks,
Jack
댓글 수: 2
"The dynamic field names are based on file names that user will import in - Field names could be any string"
Avoid doing this. It is very fragile/latent buggy code because not all valid filenames are valid fieldnames.
Consider for example these valid filenames:
'x-y'
'x.y.z'
'0'
So to make this work robustly you would need to mangle all filenames using e.g. matlab.lang.makevalidname but this still does not exclude the possibility of non-unique fieldnames, so your code could still overwrite data without any warning. You would need to add extra code to avoid overwriting data.
Basically the entire approach fragile and best avoided.
The cause is due to your forcing meta-data (e.g. filenames) into fieldnames. Meta-data is data. Data belongs in arrays, not in field or variable names. Once you store that data in an array (e.g. non-scalar structure, table, etc) then your code will be much more robust.
Jack_TDI
2023년 10월 31일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!