2

I have implemented a class in Matlab, which overloads the '+', '-' and '*' operator. Now I am interested in calculating the determinant of a Matrix whose entries consist of instances of this class. Is there a lazy way to use the symbolic determinant function of Matlab for doing this or do I have to implement a determinant Algorithm myself?

4

1 回答 1

0

您可以在您的类中创建一个名为det的函数。如果您通过使用数组而不是元胞数组来使用 Matlab OOP,则可以在实例矩阵上调用 det(M)。

class MyClass
     methods(Access=public)
          function d = det(this)
               M = zeros(size(this));
               for i=1:size(this,1)
                    for j=1:size(this,2)
                         % M(i,j) = %TODO -> convert by your own logic
                    end
               end
               d = det(M);
          end
     end
end
于 2012-01-05T12:00:17.533 回答