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?

Igor
  • 153
  • 5

1 Answers1

0

You can create a function in your class called det. If you are using Matlab OOP by using arrays, and not cell arrays, you can call det(M) on a matrix of your instances.

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
Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
  • This one would work if my object would be convertible in a number. This however is not the case. I'm interested in a general determinant function, which might return something different then a number (a polynomial for example if the matrix entries are polynomials). – Igor Jan 05 '12 at 12:11
  • @Igor, Did you try to use the symbolic toolbox? – Andrey Rubshtein Jan 05 '12 at 12:12
  • Yes. I am interested in linking the determinant function from the symbolic toolbox to my object. – Igor Jan 05 '12 at 12:19