MATLAB: Could anyone help me to solve the issue

throughput

Bmax=20;
noise=10;
A = [2 3 0 0 5;
5 6 0 0 4;
1 9 0 0 3]
B = [1 5 0 0 6;
4 3 0 0 2;
7 8 0 0 9]
P=sort(B)
G=sort(A,'descend')
% syms k
for k=1:size(G,1)
throughput =(Bmax.*log2(1+(((P).*(G))./(noise+(sum(P,1:k-1).*G)))))
end
If i run the code i am getting
Error using .*
Matrix dimensions must agree.
Error in (line 15)
throughput =(Bmax.*log2(1+(((P).*(G))./(noise+(sum(P,1:k-1).*G)))))

Best Answer

Replace
sum(P,1:k-1)
with
sum(repmat(P, 1, 1, k-1), 3)
... Or you could just think for a few seconds and instead replace sum(P,1:k-1) with P * (k-1)
Related Question