Solve MATLAB Matrix Problem: Find Basis of Kernel in MATLAB

In summary, the task is to write a program in MATLAB that will calculate the basis of the kernel for a given square matrix of the form A (mod p), where p is prime. The program should also be able to find the row echelon form and rank of any matrix of this form. The method for finding the basis is to express the variables in terms of each other, as shown in the given example. The code provided is incomplete and the author is seeking guidance on defining the variables and using loops to complete the program.
  • #1
Ermol
1
0
1. It's a MATLAB project. given a matrix of the type
A (mod p)
where p prime (and for now say the matrix is square, though i don't think this is that relevant) i need to write a program in Matlab that will calculate the basis of the kernel of the matrix. Obviously the null program wouldn't work.




Homework Equations


Prior to this I wrote the program that finds the row echelon form and the rank of any matrix of this form.


The Attempt at a Solution



What I'm trying to do is if i have a matrix of the form:

[1 . . . .
0 1 . . .
0 0 0 1 .
0 0 0 0 0
0 0 0 0 0]

or something along those lines.

Take any such matrix A, and we want to find the basis for the space of all x such that Ax=0. So we can express:
x4 in terms of x5
x2 in terms of x3 and x5
x1 in terms of x3 and x5
That was basically the hint we got, so need to express the xi corresponding to the first elements in each row that has non-zero elements in terms of the other xj.

I got this so far, though it's obviously incomplete


[m,n] = size(A);
A=echelon(A,p);

i=1:r;
j=r+1:m;
B=A(i,:)

br=B(r,:)
x(r) = br(j)*x(j) (*)


My first question is how to define an x s.t. this works? I would normally start with x=zeros(r,1), but it won't work with the code above. I would then define x(r) as in (*). Then x(r-1) and so on up til x=1. But i don't know what exactly to do.
 
Physics news on Phys.org
  • #2
I'm assuming that I would need loops to do this, but I'm not sure how to go about it. Any help would be greatly appreciated, thanks!
 

FAQ: Solve MATLAB Matrix Problem: Find Basis of Kernel in MATLAB

1. How can I find the basis of the kernel in MATLAB?

To find the basis of the kernel in MATLAB, you can use the function null or nullspace. This function will return a matrix whose columns form a basis for the null space of the given matrix.

2. What is the null space of a matrix?

The null space of a matrix is the set of all vectors that, when multiplied by the matrix, result in a zero vector. In other words, it is the set of all solutions to the equation Ax = 0, where A is the given matrix.

3. Can I find the basis of the kernel for a non-square matrix in MATLAB?

Yes, you can find the basis of the kernel for a non-square matrix in MATLAB. The null function can handle non-square matrices and will return a basis for the null space.

4. What is the difference between the null and nullspace functions in MATLAB?

The null and nullspace functions in MATLAB both return a basis for the null space of a given matrix. However, the null function can handle non-square matrices, while the nullspace function can handle only square matrices. Additionally, the null function allows you to specify a tolerance value for determining linear dependence, while the nullspace function does not have this option.

5. How can I determine the dimension of the null space of a matrix in MATLAB?

To determine the dimension of the null space of a matrix in MATLAB, you can use the nullity function. This function returns the number of linearly independent columns in the null space of the given matrix, which is equal to the dimension of the null space.

Similar threads

Back
Top