I know strjoin can be used to concatenate strings, like 'a' and 'b' but what if one of the strings is a variable, like
a=strcat('file',string(i),'.mat')
and I want:
strjoin({'rm',a})
MATLAB throws an error when I attempt this, and it's driving me crazy!
Error using strjoin (line 53) First input must be a string array or cell array of character vectors
strcatagain?strjoinis, per the documentation, for joining strings contained in an array.sprintf()will also do the job.stringandcharclasses are not the same. Perstrcat's documentation, if any input is astring, then the output is astring, soais a string.'rm'is not a string, it's a character vector, so the cell array you edited in is not a cell array of character vectors. I don't agree with MATLAB's unyielding differentiation ofstringandchar, but the error message is sufficiently explanatory.strcat('rm', a)still works fine.