adds corresponding matrices of same sizes or empty inside cell array %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: cell_add adds corresponding matrices of same sizes or empty inside cell array CALL: [cell3] = ssm.cell_add(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 % adds corresponding matrices of same sizes or empty inside cell array 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: cell_add adds corresponding matrices of same sizes or empty inside 0005 % cell array 0006 % 0007 % CALL: [cell3] = ssm.cell_add(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 0031 0032 function a = cell_add(a,b) 0033 Nrow = size(a,1); 0034 Ncol = size(a,2); 0035 for i=1:Nrow 0036 for j=1:Ncol 0037 if isequal(a{i,j}, []) 0038 if ~isequal(b{i,j}, []) 0039 a{i,j}=b{i,j}; 0040 end 0041 else 0042 if ~isequal(b{i,j}, []) 0043 try 0044 a{i,j} = a{i,j} + b{i,j}; 0045 catch ME 0046 a{i,j} = sym(a{i,j}) + sym(b{i,j}) 0047 end 0048 end 0049 end 0050 end 0051 end 0052 end