Reshape Cell array dimensions

3 次查看(过去 30 天)
Marcelo Boldt
Marcelo Boldt 2020-9-16
Dear Community,
I am facing a problem with a cell array dimension. After obtaining it with a for loop the dimension of it is 88x88 containing 6x6 matrix inside each variable. What I want to do is to change it to 176x176 cell array containing a 3x3 matrix as a variable. This is where I am currently stucked at:
Gesamtsystem_Kugel = cell(88,88);
for ki = 1:88
for ji = 1:88
if ki == ji
Gesamtsystem_Kugel{ki,ji} = Ubertragungsmatrix_sp{ki,:};
elseif ki == ji-1
Gesamtsystem_Kugel{ki,ki+1} = -Einheitsmatrix;
else
Gesamtsystem_Kugel{ki,ji} = Matrix_0;
end
end
end
New_Gesamtsystem_Kugel = reshape(Gesamtsystem_Kugel,[],[176,176]);
But Unfortunately its not working. I'm getting "Error using reshape
Size arguments must be integer scalars."
Could you please help me?

回答(1 个)

Walter Roberson
Walter Roberson 2020-9-16
reshape() is not able to do anything close to that. It can never repackage the data into other containers. All that reshape can do is change the numbering used to represent memory, such as re-arranging
1
2
3
4
to
1 3
2 4
What you need is something like
New_Gesamtsystem_Kugel = mat2cell(cell2mat(Gesamtsystem_Kugel), 3 * ones(1,176), 3 * ones(1,176));

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by