在matlab里面些写一个自定函数,用于求解矩阵 乘积
1个回答
2013-07-10
展开全部
function XY=matrix_multi(X,Y)
%This function is to achieve the operation of multi between X and Y.
%X and Y are two matrixes input.[m,n]=size(X);
[p,q]=size(Y);
if n~=p%判断第一个矩阵的列数是否等于第二个矩阵的行数
display('Illegal input!');
else
XY=zeros(m,q);
for i=1:m
for j=1:q
XY(i,j)=X(i,:)*Y(:,j);
end
end
end
%This function is to achieve the operation of multi between X and Y.
%X and Y are two matrixes input.[m,n]=size(X);
[p,q]=size(Y);
if n~=p%判断第一个矩阵的列数是否等于第二个矩阵的行数
display('Illegal input!');
else
XY=zeros(m,q);
for i=1:m
for j=1:q
XY(i,j)=X(i,:)*Y(:,j);
end
end
end
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询