0
votes

This has been a fairly trivial error for me in the past, but I am not seeing it here.

 >> rmatrix = zeros(size(Rx,1), size(Rx,2));
 for k = 1:size(Rx,1)
     for l = 1:size(Rx,2)
         rmatrix(k,l) = [Rx(k,l).^2, (Ry(k,l)).^2];
     end
 end
??? Subscripted assignment dimension mismatch.
3
Hi, you should learn how to debug with Matlab. You could have figure out what was wrong on your own, in a few minutes. mathworks.com/help/techdoc/matlab_prog/f10-60570.html - CTZStef

3 Answers

9
votes
rmatrix(k,l) = [Rx(k,l).^2, (Ry(k,l)).^2];

you're trying to assign a 1x2 matrix to a 1x1 matrix

perhaps you intended to do the following:

rmatrix = zeros(size(Rx,1), size(Rx,2),2);
for k = 1:size(Rx,1)
    for l = 1:size(Rx,2)
        rmatrix(k,l,:) = [Rx(k,l).^2, (Ry(k,l)).^2];
    end
end

//edit: which you could do a lot easier with:

rmatrix = cat(3,Rx,Ry).^2
2
votes
 >> rmatrix = zeros(size(Rx,1), size(Rx,2));
 for k = 1:size(Rx,1)
     for l = 1:size(Rx,2)
         rmatrix(k,l) = [Rx(k,l).^2, (Ry(k,l)).^2];  % CHECK THIS LINE
     end
 end
??? Subscripted assignment dimension mismatch.
1
votes

The problem is this surely??

    rmatrix(k,l) = [Rx(k,l).^2, (Ry(k,l)).^2]; 

You assign a vector to a scalar element of your array. Is this not the problem?