How to store all the results in a cell?
1 次查看(过去 30 天)
显示 更早的评论
Suppose there is a cell "d" and its size 6*6
and I want to perfom a calculation on it and store all the results in "d11"
I tried the following but I got only the last index but I want all the results.
What I have to modify?
d11 = cell(6,6);
d = num2cell(rand(6));
for i = 6
for j= 6
d1 = [d{i,j};zeros(1,size(d{i,j},2))];
d11{i,j} = d1
end
end
0 个评论
采纳的回答
Image Analyst
2023-7-22
You didn't say what you expect, and the code is so wrong in so many ways that I can't figure out what you want. So I made this attempt.
d11 = cell(6,6);
d = num2cell(rand(6))
[rows, columns] = size(d11);
for col = 1 : columns
for row = 1 : rows
thisCellContents = [d{row, col}; zeros(rows, 1)];
d11{row, col} = thisCellContents;
end
end
celldisp(d11)
Is it what you want?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!