Clear Filters
Clear Filters

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

1 view (last 30 days)
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 Comment
Jan
Jan on 24 Dec 2020
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)"?

Sign in to comment.

Answers (0)

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!