How to insert a cell with string into a table as variable
20 次查看(过去 30 天)
显示 更早的评论
I have a cell B of 1x59 strings in it and i want to insert it into a table T as variable names
When am using the command
T.VariableNames.Properties = B; am getting the following error
"The VariableNames property is a cell array of character vectors. To assign multiple variable names, specify names in a
string array or a cell array of character vectors."
I checked multiple times by checking whether the cell is str from command iscellstr and it returns me 1.
Can anyone please help how to solve this problem
1 个评论
Walter Roberson
2021-4-22
You cannot use a cell array of strings. You need to use a cell array of character vectors, or you need to use a non-scalar string() array.
采纳的回答
Stephan
2021-4-22
编辑:Stephan
2021-4-22
The solution is inside the error message:
- B is a cell array of strings
- specify names in a string array or
- cell array of character vectors
What you have is 1. and what you need is either 2. or 3.
A = {"Name1", "Name2", "Name3"}
A_new = [A{:}]
7 个评论
Walter Roberson
2021-4-23
Variable names with dots in them are permitted, R2019b and later (if I remember correctly.) You did not happen to indicate which release you are using.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!