Closed billtubbs closed 2 years ago
The only way I've found to convert them is this, but its not very pretty...
cv_names = convertStringsToChars([model_data.cvs.names{:}]);
Hey, you can use cellstr
to convert a cell of strings to a cell of char arrays.
Also, they implemented string array support for tables somewhere between R2018a and R2021b if upgrading is an option for you. In that case you could set the ConvertToArray
option of yaml.loadFile
to true
to get an array of strings, which you can pass to table
.
Thanks very much. Didn't know about cellstr
. Also, yes I need to upgrade. I'm still using R2019b.
Excellent, and useful tool. Thanks.
I'm using it to store information on variables with names. For example, my Yaml file might contain:
After loading the yaml file to a struct called
model_data
these names become a cell array as expected:However, tables don't seem to accept cell arrays of strings and seem to require char
Is there a way to force a cell array of character vectors instead of strings? Or, any other ideas on how to easily populate the RowNames or VariableNames properties of tables?