Inverse matrix with for loop, dimensions are wrong I don't know how to fix it
1 次查看(过去 30 天)
显示 更早的评论
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
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 Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!