This looks like a very sparse matrix, right? Then I would first figure out how to assign the blocks of Aineq from its components, something like this:
blksz = [3,13];
nBlks = 15;
Aineq = zeros(blksz*nBlks);
for i1 = 1:nBlks
for i2 = 1:nBlks
Aineq((1:blksz(1))+blksz*(i1-1),(1:blksz(2))+blksz(2)*(i2-1)) = CurrBlk;
end
end
Once you've figured that one out, you should look at what components of every block is non-zero and start to build sparse blocks, and then concatenate them instead, that would be much more memmory efficient. Then the last step (or preferably the firts, but I find it easier to move to sparse representations of comlex matrices step-by-step), is to calculate vectors with the row and column-indices and the corresponding matrix element and then simply concatenate those into three arrays i_rows, i_cols, val and then call sparse:
Asparse = sparse(i_rows,i_cols,vals,nRows,nCols);
HTH
Best Answer