when i run this script i get an error 'Field assignment to a non-structure array object.' in line 10
4 次查看(过去 30 天)
显示 更早的评论
clear
clc
k=4;
l = "tile%d";
str = sprintf(l,k);
str.value={};
str.bonus={};
str.value=4
str.bonus='dots'
0 个评论
回答(1 个)
Star Strider
2017-9-17
Your ‘str’ variable is a character array or a (1x1) string object, not a structure. You cannot address it as a structure.
If you want to create a structure, see the documentation on struct (link) and related documentation for details.
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!