MATLAB: Function ‘subsindex’ is not defined for values of class ‘string’

stringsubsindex

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

Best Answer

Rename the variable named title in your workspace so you can use the title function again.
When the error message refers to subsindex, it means you're trying to use an object as the index into a variable but MATLAB doesn't know how to interpret that object as an index and the variable into which you're trying to index hasn't had its indexing implemented to handle that situation.
In your case, you've done something like this but with potentially many lines between the first and second line of my example (so you forgot you created a variable named title) and with title instead of f as the name.
>> f = (1:10).^2;
>> f("5")
Function 'subsindex' is not defined for values of class 'string'.