merge parts of arrays of cell array into matrix using loop
이전 댓글 표시
Hi guys!
I have a cell array:
solution = 1×6 cell array
Columns 1 through 6
{6×300 double} {6×300 double} {6×300 double} {6×300 double} {6×300 double} {6×300 double}
Later it will be a cell arrays of 1 x 14000
I need to find a way to merge the first 20 elements (Ns*Nz) of the first row of each cell array.
This is what I basicly need:
sol = solution;
cC0_ges = [sol{1,1}(1,1:Nz*Ns); sol{1,2}(1,1:Nz*Ns); sol{1,3}(1,1:Nz*Ns); sol{1,4}(1,1:Nz*Ns); sol{1,5}(1,1:Nz*Ns); sol{1,6}(1,1:Nz*Ns)];
cC1_ges = [sol{1,1}(1,Nz*Ns+1:2*Nz*Ns); sol{1,2}(1,Nz*Ns+1:2*Nz*Ns); sol{1,3}(1,1:Nz*Ns); sol{1,4}(1,1:Nz*Ns+1:2*Nz*Ns); sol{1,5}(1,1:Nz*Ns+1:2*Nz*Ns); sol{1,6}(1,1:Nz*Ns+1:2*Nz*Ns)];
And so on - but I cant do this manually for 14000 times.
So what I tried is:
for j = 0:5
j = j + 1;
cC0_ges = solution{1,j}(1,1:Nz*Ns); %sol{1,2}(1,1:Nz*Ns); sol{1,3}(1,1:Nz*Ns); sol{1,4}(1,1:Nz*Ns); sol{1,5}(1,1:Nz*Ns); sol{1,6}(1,1:Nz*Ns)];
end
And
cC0_ges = [solution{1,:}(1,1:Nz*Ns)]'
But apparently it is not right.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!