%% Creating cell array examples
%

%% Creating cell arrays
%
% There are different ways of assigning data to cell arrays.
%
% 1) cell indexing
%
% Assuming that the structure cruisedata from the previous example still
%  exists.
c(1,1) = {rand(3)};
c(1,2) = {'alpha'};
c(2,1) = {13};
c(2,2) = {cruisedata};
%%
% Note the curly brackets on the right-hand-side. They indicate the contents
% of a cell. Round brackets refer to the elements of an array as usual.  
%

c

%% 
% 2) content indexing
%
% We can create the same arrays as follows:
c{1,1} = rand(3);
c{1,2} = 'alpha';
c{2,1} = 13;
c{2,2} = cruisedata;
%%
% Here the curly braces on the left indicate the content of the cell in the
% particular location.
%

%%
% 3) using curly braces to contruct the whole cell at once
b = {[1:5] rand(2); cruisedata 'beta'};

%% Accessing data in cell arrays
%
% To access the elements of cell arrays use the curly brackets.
r = c{1,1};
r

%%
% Or access a subset using a combination of curly and round brackets.
r23 = c{1,1}(2,3);
r23

%%
% In nested cell arrays the curly braces can be concatenated.

%% Visualizing cell arrays
%
% This function displays the cell array graphically. 
cellplot(c,'legend')


