필터 지우기
필터 지우기

How to do this Matrix Operation...?

조회 수: 3 (최근 30일)
CHANDRA SHEKHAR BESTA
CHANDRA SHEKHAR BESTA 2014년 4월 10일
답변: Star Strider 2014년 4월 10일
I have A=2x2 Matrix,
But each element of Matrix; again have 1x4 Matrix(i.e.,A11(1x4)).
How can i read this elements.
for example:
A=[[1 2 3 4],[5 6 7 8];[11 12 13 14],[15 16 17 18]];
i.e.,
A{1,1}=[1 2 3 4];
A{1,2}=[5 6 7 8];
A{2,1}=[11 12 13 14];
A{2,2}=[15 16 17 18];
I want like this;
O{1,1}=[1 5; 11 15];
O{1,2}=[2 6; 12 16];
O{2,1}=[3 7; 13 17];
O{2,2}=[4 8; 14 18];
For this how can i write Program/Syntax...

답변 (1개)

Star Strider
Star Strider 2014년 4월 10일
This works:
% Original data:
A{1,1}=[1 2 3 4];
A{1,2}=[5 6 7 8];
A{2,1}=[11 12 13 14];
A{2,2}=[15 16 17 18];
% Create intermediate matrices:
O1 = cell2mat(A);
O2 = reshape(O1', [4 4])
% Create cell vector:
for k1 = 1:4
O{k1} = O2(k1,:);
end
% Create cell output array:
O = reshape(O, [2 2])'
% View output:
O{1,1}
O{1,2}
O{2,1}
O{2,2}

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by