The error message you encountered is "first argument must be a string array, character vector, or cell array of character vectors". This error occurred in the totable
function on line 38, specifically in the line [n, modified1] = matlab.lang.makevalidname(input.name);
.
To resolve this error, make sure that the input argument input.name
is of the correct type. totable
function expects the input argument to be a string array, a character vector, or a cell array of character vectors.
Here are a few steps you can follow to resolve this error:
input.name
variable. Verify if it is indeed a string array, character vector, or cell array of character vectors. You can use the class
function to inspect its type.main.m24 chars2 lines
input.name
is not one of the expected types, you can convert it to the correct type. For example, if input.name
is a cell array of strings, you can use the cellstr
function to convert it into a string array.main.m34 chars2 lines
input.name
is correct, but you still encounter the error, you may need to check the elements of the string array or cell array for any invalid characters. The makevalidname
function is used to replace any invalid characters with valid ones. You can use the function on individual elements of the array or cell array before passing it to totable
.main.m165 chars6 lines
Once you have made the necessary changes, you can try running your code again and see if the error persists.
gistlibby LogSnag