multiplies block defined matrix stored inside cell array %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: cell_mult multiplies block defined matrix stored inside cell array CALL: [cell3] = ssm.cell_mult(cell1,cell2) INPUTS: cell1 - cell array of matrices representing a matrix by blocs. blocs may be empty cell2 - cell array of matrices representing a matrix by blocs. blocs may be empty OUTPUTS: cell3 - cell array of matrices representing a matrix by blocs. blocs may be empty ***** There are no parameters ***** VERSION: '$Id: $' HISTORY: 07-08-2008 TO DO : check ME in case of mixed symbolic and double %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % multiplies block defined matrix stored inside cell array 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: cell_mult multiplies block defined matrix stored inside cell 0005 % array 0006 % 0007 % CALL: [cell3] = ssm.cell_mult(cell1,cell2) 0008 % 0009 % INPUTS: 0010 % cell1 - cell array of matrices representing a matrix by blocs. 0011 % blocs may be empty 0012 % cell2 - cell array of matrices representing a matrix by blocs. 0013 % blocs may be empty 0014 % 0015 % OUTPUTS: 0016 % cell3 - cell array of matrices representing a matrix by blocs. 0017 % blocs may be empty 0018 % 0019 % ***** There are no parameters ***** 0020 % 0021 % VERSION: '$Id: $' 0022 % 0023 % 0024 % HISTORY: 0025 % 07-08-2008 0026 % 0027 % TO DO : 0028 % check ME in case of mixed symbolic and double 0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0030 function c = cell_mult(a,b) 0031 n1 = size(a,1); 0032 n2 = size(a,2); 0033 n3 = size(b,2); 0034 c = cell(n1,n3); 0035 for i=1:n1 0036 for j=1:n3 0037 for k=1:n2 0038 if ~(isequal(a{i,k}, []) || isequal(b{k,j}, [])) 0039 0040 if isempty(c{i,j}) 0041 c{i,j} = a{i,k}*b{k,j}; 0042 else 0043 try 0044 c{i,j} = c{i,j} + a{i,k}*b{k,j}; 0045 catch 0046 c{i,j} = sym(c{i,j}) + sym(a{i,k})*sym(b{k,j}); 0047 end 0048 end 0049 end 0050 end 0051 end 0052 end 0053 end