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

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

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개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2020년 12월 24일

댓글:

Jan
2020년 12월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by