Reputation: 21
This requires a little knowledge about Matlab and I have none. I was just wondering if someone could point me in the right direction and give me some pointer :)
I have to write a matlab code for finding the Null spaces of matices A and B, where B = A^T x A. And then nd the general solutions to AX = b1 and BX = b2, where b1= the column [1 2 3 4 5] and b2= the column [ 1 2 3 4 5 6 7 8]. My concern is that I dont really know how to go about this code. This is what I have so far and I do not think i am in the right track. I have a specific matrix as below. The rows are divided by semi-colon.
A = [ 1 2 3 4 5 6 7 8;
1 2^2 3^2 4^2 5^2 6^2 7^2 8^2;
1 2^3 3^3 4^3 5^3 6^3 7^3 8^3;
1 2^4 3^4 4^4 5^4 6^4 7^4 8^4;
6 8 1 1 7 9 0 7 ]
B = A’A (this is how transpose is written)
C = null(A)
D = null(B)
I feel like there should be a rref somewhere - I'm just not getting anywhere. Please point me in the right direction.
Ok so I updated it to the this now....My username changed from jona and I dont know why
A = [ 1 2 3 4 5 6 7 8;
1 2^2 3^2 4^2 5^2 6^2 7^2 8^2;
1 2^3 3^3 4^3 5^3 6^3 7^3 8^3;
1 2^4 3^4 4^4 5^4 6^4 7^4 8^4;
6 8 1 1 7 9 0 7 ]
B = A’*A (this is how transpose is written)
null(A)
null(B)
b1=[1; 2; 3; 4; 5 ];
b2=[1; 2; 3; 4; 5; 6; 7; 8 ];
end
rref(A,b1)
rref(B,b2)
end
However I still don't feel this is right :(
@Chris A. I know the null space is the solution to Ax=0. However I'm confused on how to use it to find general solution using the b1 and b2 I have. Is it possible for you to explain to me the connection? I don't undertand the book as much.
Upvotes: 2
Views: 1404
Reputation: 6887
Ok, so the bottom line is that the null space is the set of all vectors x
such that A * x = 0
. You got that right. And C
is an orthonormal basis for the vectors in the null space. So that means if you have a particular solution (let's call it v
) such that A * v = b1
then the space of solutions is the vector v
plus any combination of vectors in the null space.
For the case of A
, the size (second dimension) of your C
will tell you the dimension of the null space. Each one of the vectors in C
will be a vector in the null space.
To get v
you can do v = A \ b1
. You can write arbitrary combinations of vectors in C
by C * c
where little c
is a column vector that is the size of the null space.
The general solution is thus v + C * c
where c
is any vector that is the dimension of the null space. To see that this solve the system, just plug it back in
A * (v + C * c) =
A * v + A * C * c =
b1 + 0 * c =
b1
Edit: It's the exact same idea for finding the solution to A'*A * x = b2
, just anywhere you see A
in the above discussion, replace it with A'*A
and anywhere you see b1
replace it with b2
. The solutions to A * x = b1
and A'*A * x = b2
are separate problems.
Upvotes: 1
Reputation: 42235
In MATLAB, arithmetic operations need to be explicit, i.e. a(b+c)
should be written as a*(b+c)
Have you tried writing B
as
B=A'*A;
Also, you seem to be using a different character for the transpose... You're using ’
, the unicode character for single right quotation when you should be using '
or the unicode character for apostrophe.
Upvotes: 2