Struct field name with space or special character
31 views (last 30 days)
Show older comments
Hi,
For table name, we can use space or special character when using stiring type.
However for the structure varailble,it doesn't work. Is there a way to have space in structure field names?
thanks,
2 Comments
Stephen23
on 19 Feb 2024
Edited: Stephen23
on 19 Feb 2024
This sounds like you are putting meta-data into the fieldnames. Remember that meta-data is data, and data belongs in variables not in their field/variable names. forcing meta-data into field/variable names will make your code fragile (e.g. like this question hints at), slow, and complex. Best avoided.
Answers (2)
Matt J
on 18 Feb 2024
Another option is to use dictionaries, which are a bit more similar to structs than tables, e.g.
secretID=["Steve Rogers", "Tony Stark", "Donald Blake"];
hero=["Captain America","Iron Man","Thor"];
d=dictionary(secretID,hero);
out = d("Steve Rogers")
0 Comments
See Also
Categories
Find more on Structures 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!