clc
clear all

A(1,1) = {[1 4 3; 0 5 8; 7 2 9]};

A(1,2) = {'Anne Smith'};

A(2,1) = {3+7i};

A(2,2) = {-pi:pi/10:pi};

A

class(A)

B{1,1} = [1 4 3; 0 5 8; 7 2 9];

B{1,2} = 'Anne Smith';

B{2,1} = 3+7i;

B{2,2} = -pi:pi/10:pi;

B

class(B)

pause
clear all
clc
%-------------------------------------------------------------------------
%                  cell arrays
%-------------------------------------------------------------------------
% try as matrix using []

x = {[2 1 3;4 5 2]       2        [3 4 3]';... 
    'first'          'second'     'third';...
    ones(1,50)        zeros(25)     'hidden'}

% view vector values in position 3,3
curlyValue_x33 = x{3,3}
curlyClass_x33 = class(x{3,3})     % class = char
curlyValue3_x33 = x{3,3}(3)         % value of 3rd element in vector @ 3,3

pause
disp('-------------------------------------');
% view contents of 3,3
smooth_x33 = x(3,3)
smoothClass_x33 = class(x(3,3))     % class = cell
%x(3,3)(3)         % not legal

pause

disp('-------------------------------------');
% access specific location and change its value
x{3,2}(2,5) = 25

x{3,2}


%-------------------------------------------------------------------------
%                  build cell array
%-------------------------------------------------------------------------
% clear all
% clc
% 
% a = cell(4)
% 
% a{2,3} = 'test'
% 
% b = cell(size(a))



%-------------------------------------------------------------------------
%                  convert cell to matrix
%-------------------------------------------------------------------------
% clear all
% c = {[1],    [2, 3, 4];
%      [5; 9], [6, 7, 8; 10, 11, 12]};
% 
% m = cell2mat(c)
% 
% d = {'test',    [2, 3, 4];
%      [5; 9], [6, 7, 8; 10, 11, 12]};
% 
% n = cell2mat(d)



%-------------------------------------------------------------------------
%                  convert cell to struct
%-------------------------------------------------------------------------
% first cell is 5 year, 2nd cell 10 year, 3rd cell 15 year
% clear all
% 
% devel = {{'Lee','Reed','Hill'}, {'Dean','Frye'}, {'Lane','Fox','King'}};
% sales = {{'Howe','Burns'}, {'Kirby','Ford'}, {'Hall'}};
% mgmt = {{'Price'}, {'Clark','Shea'}, {'Sims'}};
% qual = {{'Bates','Gray'}, {'Nash'}, {'Kay','Chase'}};
% docu = {{'Lloyd','Young'}, {'Ryan','Hart','Roy'}, {'Marsh'}};
% 
% employees = [devel; sales; mgmt; qual; docu]
% 
% rowHeadings = {'development', 'sales', 'management', ...
%                'quality', 'documentation'};
% 
% depts = cell2struct(employees, rowHeadings, 1)
% [fiveYear_devel,tenYear_devel] = depts(1:2).development
% 
% colHeadings = {'fiveYears' 'tenYears' 'fifteenYears'};
% 
% years = cell2struct(employees, colHeadings, 2)
% 
% years.fiveYears
% years(1).fiveYears
% 
% 
% 
% %-------------------------------------------------------------------------
% %                  add to cell array
% %-------------------------------------------------------------------------
% clear all
% C = {1, 2, 3};
% 
% % add 3 rows and 1 col and assign value to 4,4
% C{4,4} = 44
% 
% % add row and column
% C{5,5} = []
% 
% % delete row
% C(5,:) = []
% 
% % delete value
% C{1,1} = []
% 
% % insert string
% C{1,1} = 'bieber'
% 
% 
% 
% %-------------------------------------------------------------------------
% %                  combine cell arrays
% %-------------------------------------------------------------------------
% clear all
% C1 = {1, 2, 3};
% C2 = {'A', 'B', 'C'};
% C3 = {10, 20, 30};
% 
% C4 = [C1; C2; C3]
% 
% C5 = {C1; C2; C3}
% 
% C5(1)
% C5{2}
% 
% 
% 
% %-------------------------------------------------------------------------
% %                  plots
% %-------------------------------------------------------------------------
% clear all
% randCell = {'Random Data', rand(20,2)};
% plot(randCell{1,2})
% title(randCell{1,1})
% 
% figure
% plot(randCell{1,2}(:,1))
% title('First Column of Data')
% 
% % using cell2mat
% temperature(1,:) = {'01-Jan-2010', [45, 49, 0]};
% temperature(2,:) = {'03-Apr-2010', [54, 68, 21]};
% temperature(3,:) = {'20-Jun-2010', [72, 85, 53]};
% temperature(4,:) = {'15-Sep-2010', [63, 81, 56]};
% temperature(5,:) = {'31-Dec-2010', [38, 54, 18]};
% 
% allTemps = cell2mat(temperature(:,2));
% dates = datenum(temperature(:,1), 'dd-mmm-yyyy');
% 
% plot(dates, allTemps)
% datetick('x','mmm')
% 
% 
% 
% %-------------------------------------------------------------------------
% %                  adding text strings
% %-------------------------------------------------------------------------
% clear all
% 
% d = cell(3)
% 
% d{1,2} = 'string 1'
% 
% d{1,2} = strcat(d{1,2},' and string 2')
% 
% d{1,2}
% 
% d(1,2)
% 
% d{1,2}(5:9)