function 'subsindex' is not defined for values of class 'string'
显示 更早的评论

This is roughly my code Only sometimes I have less or more inputs in the array "nam" In some situations i get the error " 'subsindex' is not defined for values of class 'string'" I looked for this, but could not find it and I do not understand what the error message means.
nam = ["t1" , "t3" , "t4"];
for j=1:3
figure
title( ['title start' nam(j) ] )
end
5 个评论
Fangjun Jiang
2018-6-21
Must be somewhere else. There is no error if you just run the code above.
Stephen23
2018-6-21
@Mattijs Mientki: please show is the complete error message. This means all of the red text.
Mattijs Mientki
2018-6-21
编辑:Mattijs Mientki
2018-6-21
Geoff Hayes
2018-6-21
编辑:Geoff Hayes
2018-6-21
Mattijs - is nam always an array or can it just be a string (in your code)? For example, if you have
someString = "hello";
someString(1)
What happens? Unfortunately, my version of MATLAB doesn't support creating strings (as opposed to character arrays) so I am wondering if, in some cases, your nam is just a string and not an array of strings and so treating the string object as if it were an array (using nam(j)) generates the error...
Mattijs Mientki
2018-6-21
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!