![]() |
| Script struct_cell_cell.m | |||
|
|||
|
%A Structure and a cell within a Cell
%We define numerical, string, %cell and logical arrays a_num=[19 9 4; 17 3 5]; a_char=['January ';'February']; a_cell={1 4;8 2;9 2}; a_logical=a_num<10; %then a struct arrays a_struct(1).month=a_char(1,:); a_struct(2).month=a_char(2,:); a_struct(1).log=a_logical(1,:); a_struct(2).log=a_logical(2,:); a_struct % and at end we assemble all arrays %in a new cell array A_cell={a_num, a_cell, a_struct} %INDEXING %using indexing with parentheses %we find only the type of an element %using curly braces we obtain its content %in a simple way for the first two elements %and in a less simple mode for the third %element that is a structure a_par1=A_cell(1) a_cur1=A_cell{1} a_par2=A_cell(2) a_cur2=A_cell{2} a_cur31=A_cell{2}{3,1} a_cur32=A_cell{2}{3,2} a_par3=A_cell(3) a_cur3_month=A_cell{3}(1).month(1,:) a_cur3_log=A_cell{3}(1).log(1,:) |
|||
| Back | |||