Attachment 'Aufgabe2.m'
Download 1 function d = Aufgabe2(A, k)
2 %Aufgabe2 - compute determinant of a matrix by recursion over its minors.
3 %
4 %usage
5 % d = Aufgabe2(A, k)
6 %
7 %input
8 % A : (n,n)-matrix.
9 % k : Row index in A.
10 %
11 %output
12 % d : Determinant of A.
13 %
14 %description
15 % Aufgabe2 computes the determinant of A by summing over the determinants of its
16 % minors in row k. The determinants of the minors are computed by recursion where
17 % the trivial case is a (1,1)-matrix.
18 %
19 %author
20 % buenau@cs.tu-berlin.de
21
22 [n,m] = size(A);
23 if n ~= m, error('Matrix ist nicht quadratisch'); end
24
25 if n == 1
26 % Trivial case.
27 d = A(1,1);
28 else
29 d = 0;
30 % Sum over minors in row k.
31 for j = 1:n
32 d = d + ((-1).^(k+j) )*A(k,j) * Aufgabe2(A([1:(k-1) (k+1):n], [1:(j-1) (j+1):n]), k-1);
33 end
34 end
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.