clear all;
clc;

%% Matlab programming: data types and structures

% The principal data type is the N-dimensional array
a = [1 2 3]
b = [1 2 3 4; 5 6 7 8]

% access the elements
a(2)
b(1,3)
b(:,3)

% the ":" operator to specify the sequences
1:4
1:2:10
1:.1:.4

% sub-array
b(:, 2:3)
b(1, 2:end)

% a matrix is interpreted as the concatenation of its colums
b(:)

% arrays with dimensionality greather than 2
c(:,:,1) = [1 2 3; 4 5 6]
c(:,:,2) = [7 8 9; 0 1 2]

%% Heterogeneous containers 

% cell: array generalization; elements of the same cell can have
% different data type 
d{1} = a
d{2} = b
d{2,3} = c

% structure: collection of heterogeneous elements indexed by name
% (field)
s.data = a
s.name = 'example'