Script cell_3D.m
Download Script cell_3D.m
%we define six cell arrays
%four are of size 1x1 and two 1x2
c111={'James'};
c121={'Joyce'};
c112={'Ulysses'};
c122={'Finnegans Wake'};
c21={1882 1941};
c22={1922 1939};
%cells are concatenated
%using curly braces
%into cells of sizes 2x2
cp1={c111 c121;c21(1),c21(2)}
cp2={c112 c122;c22(1),c22(2)}
%we see their contents
%it they are concatenated
%if we use square brackets
c_p1=[c111 c121;c21]
c_p2=[c112 c122;c22]
%cells are concatenated
%using curly braces
%into a cell of size 1x2
c_row_curly={c_p1 c_p2}
%into a cell of size 2x1
c_col_curly={c_p1;c_p2}
%we see their contents
%it they are concatenated
%if we use square brackets
c_row_brackets=[c_p1 c_p2]
c_col_brackets=[c_p1;c_p2]
%cells are concatenated
%using square brackets
%into a cell of size 2x2x2
c_3D(:,:,1)=c_p1;
c_3D(:,:,2)=c_p2;
c_3D
whos

Back