Unable to perform assignment because the left and right sides have a different number of elements.
1 次查看(过去 30 天)
显示 更早的评论
i=3;
clmax= zeros(i,1);
for j = 1: 1: i
clmax(j) = del (j).clmax;
end
5 个评论
回答(1 个)
Jan
2021-6-30
编辑:Jan
2021-6-30
The error means, that the contents of the fields clmax are not scalar. Check this:
clmax = {del.clmax};
s = cellfun('prodofsize', clmax)
Storing the data in a cell array is the best way, if the fields have different sizes. If call have the same dimension, you can concatenate them to a matrix or a n-dim array:
clmax = cat(1, del.clmax) % Or 2, 3, or what ever
You see, that neither for a cell array nor for a numerical array a loop is required.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!