Retrieving strings from struct variable
显示 更早的评论
Hello,
What I am trying to do is retrieve strings from a struct variable and store them in a vector. The struct variable is 16x1 with the first field holding the string data.
Here is what I tried, for example:
---------------
for i = 1:16
stringVector(i) = structVar(i).stringField;
end
---------------
Here is the error I am receiving:
"??? In an assignment A(:) = B, the number of elements in A and B must be the same."
Any thoughts?
采纳的回答
更多回答(2 个)
Fangjun Jiang
2011-7-20
Your strings may have different length. Thus, it is better to use cell array of strings. change your line to be:
stringVector{i} = structVar(i).stringField
类别
在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!