12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

matrices, strings, structures, or other cell arrays. For example, to createa2× 2 × 2 cell array we can type:a = {[1 2] ’hello’; 3[5;6]};b = {spiral(3) eye(2) ; ’good’ ’bad’};c = cat(3,a,b);The cat function concatenates arrays a <strong>and</strong> b along dimension number 3.To visualize this array we can use celldisp <strong>and</strong> cellplot as we didbefore. For example:cellplot(c)The contents <strong>of</strong> the cells are only indicated for the front “page” <strong>of</strong> themultidimensional cell array. To see other pages you can include subscriptsinto the cell array:cellplot(c(:,:,2))To access cells use curly bracket indexing <strong>and</strong> to access cell contents useround bracket indexing:>> c{1,2,2}ans =1 00 1>> c{1,2,2}(1,:)ans =1 029.6 Multidimensional StructuresMultidimensional structures have dot-separated field names, but theyare accessed using an arbitrary number <strong>of</strong> subscripts. For example,>> staff(2,1,2).name = ’Joe Bloggs’staff =2x1x2 struct array with fields:c○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!