how do I multiply two matrices

조회 수: 19 (최근 30일)
Lawrence Lee
Lawrence Lee 2017년 12월 27일
답변: KSSV 2017년 12월 27일
Hi
a = [1,2,3;9,8,7] b = [5,8;8,7;9,4] I can't figure out how a*b = [48,34;172,156]?
thanks
  댓글 수: 1
KSSV
KSSV 2017년 12월 27일
It is basic...multiplying two matrices......are you aware of how to multiply two matrices?

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2017년 12월 27일
a = [1,2,3;9,8,7] ;
b = [5,8;8,7;9,4] ;
% ab = [48,34;172,156] ;
[n,p] = size(a) ;
[p,m] = size(b) ;
C = zeros(n,m) ;
for i=1:n
for j=1:m
C(i,j)=0.0;
for k=1:p
C(i,j) = C(i,j)+a(i,k)*b(k,j);
end
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by