views:

110

answers:

2

A(N,N): matrix

First, i want to give the matrix from my keyboard. Then calculate the determinant of A

Thanks!

+4  A: 

You can define the matrix like so (semicolons can be used for line breaks)

A = [1 2 3; 4 5 6; 7 8 0]
A =
     1     2     3
     4     5     6
     7     8     0

Then you calculate the determinate by using DET

det(A)

ans =
           27
Jonas
i want the steps to calculate this determinant OK?for exemple:the determinant of a diagonal matrix is:diagonal=diag(A);determinant = -prod(diagonal);
Fisherman
@Fisherman: You're not asking how to calculate it *in Matlab*. You're asking about the algebra behind it. I'm not sure this is the correct forum for this.
Nathan Fellman
So , would you PLZ give me the correct forum. THANKS a lot!
Fisherman
@Fisherman: I don't quite understand what you need. If you want to know the determinant, then you can use the function `det`. If you want intermediate steps (i.e. L/U decomposition), you can look at the help to the function `det` I linked in my answer, where they describe the algorithm. Or you can check Wikipedia (http://en.wikipedia.org/wiki/Determinant) for many other ways for calculating the determinant.
Jonas
@Fisherman: If you need to know anything about the algorithm that goes beyond the algorithm description in the Matlab help (look at the link to LU in there as well) and in Wikipedia, I suggest this site: http://math.stackexchange.com/
Jonas
It's OK , thank you SO muchNow i find my answer that's it
Fisherman
clc;clear all;A=input ('Give me the matrix A : ');[m,n]=size(A)for i = 2:1:mfor p = 1:1:i-1A(i,:)=A(i,:)-(A(i,p)/A(p,p))*A(p,:);diagonal=diag(A);determinant = -prod(diagonal);endend
Fisherman
@Fisherman: Glad everything works now. Please consider accepting my answer if you found it useful.
Jonas
+1  A: 
A = [ 1 2 3 4;
      5 6 7 8;
      1 2 3 4;
      5 6 7 8];
det(A)
Scottie T

related questions