0
votes

I'm trying to perform a summation omega is a scaler and eigenVecs are vectors there are i (19) of them. I want to sum them into 1 vector I want to store that sumations in faceRecon{1} the next in faceRecon{2} so forth and so on.

for i =1:N/PicDup;
  for j =1:k;
    faceRecon{i} += mtimes(omega{i,j},eigenVecs{i});
  end;
end;
%N/PicDup = 7; k = 35; 

i get this error-> error: operator +: nonconformant arguments (op1 is 0x0, op2 is 11088x1);

I kind of understand the error i need to initialized op1 a cell array that is {1x7} and inside each one of those cells in need to make them 11088x1.

How do I do this? Is this even possible ? Is there a better cleaner way to do this ?

Many thanks in advanced. Any and all helps is greatly appreciated.

1
First of all, += is not a valid MATLAB operator. - Suever

1 Answers

1
votes

To fix your immediate issue, you need to initialize faceRecon such that each element contains an 11088 x 1 matrix of zeros prior to iterating through the loop.

faceRecon = repmat({zeros(size(eigenVecs{1}))}, size(eigenVecs));

Also, += is not a MATLAB operator so you'll need to do something like the following instead

thing = thing + other_thing;

Rather than using cell arrays, I would convert omega and eigenVecs to actual numeric matrices and then you can use normal matrix multiplication to perform the multiplication and subsequent summation.

w = cell2mat(omega);            % M x N
eigenV = cat(2, eigenVecs{:});  % 11088 X M;

faceRecon = eigenV * w;         % 11088 x N