필터 지우기
필터 지우기

Inverse matrix with for loop, dimensions are wrong I don't know how to fix it

조회 수: 1 (최근 30일)
Elizabeth Brito
Elizabeth Brito 2020년 12월 24일
댓글: Jan 2020년 12월 24일
C=[-2,3;
6,5]
[m,n]=size(C)
z=zeros(m,n)
%cofactor
c1= C(2,2)
c2 = -C(1,2)
c3 = -C(2,1)
c4 = C(1,1)
%cofactor matrix
c = [c1,c3;
c2,c4]
for i= 1:m
for j= 1:n
for k=1/det(C(i,j))
for h= transpose(c)
z(i,j)= k*h
end
end
end
end
  댓글 수: 1
Jan
Jan 2020년 12월 24일
Before the readers can fix your code, they need to know, what you try to do. "Inverse matrix with foor loop" is not clear enough.
det(x) is x, if x is a scalar. So "for k=1/det(C(i,j))" is the same as "k = 1 / C(i,j)".
What is the purpose of "for h= transpose(c)"?

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by