How can I make a string array consisting of strings with numerical suffixes?
5 views (last 30 days)
Cris LaPierre on 23 Nov 2022
Edited: Cris LaPierre on 23 Nov 2022
str2num won't work with a word ("sub"). It's also unnecessary if you are using sprintf.
One other correction I would make is in how you preallocate your array. The empty brackets initializes your variable Sub as a double, so all strings will appear as NaN. You need to initiallize as an empty string.
Try something like this.
Sub = strings;
Sub(i,1) = sprintf("sub%02d",i);
% view result