I'm trying to perform row multiplication with two matrices: A
and B
.
A Subscripted assignment dimension mismatch
error is thrown on the line C(1,i) = A(i,:)*B;
.
Do I have a syntax error that is causing the dimensions on the left and right sides of the =
sign to be unequal?
function C = rowproduct(A,B)
[n,m]=size(A);
[p,q]=size(B);
C=zeros(1,n);
if( m == p)
for i=1:n
C(1,i) = A(i,:)*B;
end
else
error('matrix dimension mismatch');
end
end
try to replace C(1,i) = A(i,:)*B;
with C(i,:) = A(i,:)*B;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.