Dynamic Structure FieldNames in App Designer Properties
Show older comments
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 Comments
"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
on 31 Oct 2023
Accepted Answer
More Answers (0)
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!