function 'subsindex' is not defined for values of class 'string'
Show older comments

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 Comments
Fangjun Jiang
on 21 Jun 2018
Must be somewhere else. There is no error if you just run the code above.
Stephen23
on 21 Jun 2018
@Mattijs Mientki: please show is the complete error message. This means all of the red text.
Mattijs Mientki
on 21 Jun 2018
Edited: Mattijs Mientki
on 21 Jun 2018
Geoff Hayes
on 21 Jun 2018
Edited: Geoff Hayes
on 21 Jun 2018
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
on 21 Jun 2018
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays 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!