What are the commands for...
149 次查看(过去 30 天)
显示 更早的评论
Hello there!
I am looking for the commads for...
the basis of a row space.
the basis of a column space.
and the basis of a null space.
Are there such commands out there?
Kind regards.
Morne' Breitenbach
0 个评论
采纳的回答
John D'Errico
2020-6-4
编辑:John D'Errico
2020-6-4
Column space basis orthogonal representations are obtained in MATLAB using either null or orth. In fact, they work regardless of whether the matrices are symbolic or floating point.
A = magic(4)
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
rank(A)
ans =
3
Since A has rank 3, the null space will have dimensioon 1.
null(A)
ans =
-0.223606797749979
-0.670820393249937
0.670820393249937
0.223606797749979
orth(A)
ans =
-0.5 0.670820393249937 0.5
-0.5 -0.223606797749979 -0.5
-0.5 0.223606797749979 -0.5
-0.5 -0.670820393249937 0.5
orth(A) spans the column space, which must have dimension 3. Note that on floating point inputs, null and otrth return results normalized to have unit euclidean norm for each vector.
Both column spaces will be in an ortho-normal form, thus they have Euclidean norms of 1, and the vectors will be orthogonal. At least so to within floating point precision.
B = orth(A);
B'*B
ans =
1 -1.47568580327613e-16 -5.55111512312578e-17
-1.47568580327613e-16 1 1.11022302462516e-16
-5.55111512312578e-17 1.11022302462516e-16 1
All of this works on symbolic matrices too, though the vectors need not be as neatly normalized.
B = colspace(sym(A))
B =
[ 1, 0, 0]
[ 0, 1, 0]
[ 0, 0, 1]
[ 1, 3, -3]
B'*B
ans =
[ 2, 3, -3]
[ 3, 10, -9]
[ -3, -9, 10]
So colspace here returned a basis that is independent, but not orthogonal.
On fully symbolic arrays, thus those with some or all non-numeric elements, there are other things we need to watch out for.
syms x
>> A = [1 2 3;4 5 6;7 8 x]
A =
[ 1, 2, 3]
[ 4, 5, 6]
[ 7, 8, x]
>> null(A)
ans =
Empty sym: 3-by-0
>> orth(A)
ans =
[ 66^(1/2)/66, (3*11^(1/2))/11, (x/6 - 3/2)/(abs(x/3 - 3)^2 + 2*abs(x/6 - 3/2)^2)^(1/2)]
[ (2*66^(1/2))/33, 11^(1/2)/11, -(x/3 - 3)/(abs(x/3 - 3)^2 + 2*abs(x/6 - 3/2)^2)^(1/2)]
[ (7*66^(1/2))/66, -11^(1/2)/11, (x/6 - 3/2)/(abs(x/3 - 3)^2 + 2*abs(x/6 - 3/2)^2)^(1/2)]
>> colspace(A)
ans =
[ 1, 0, 0]
[ 0, 1, 0]
[ 0, 0, 1]
Both orth and colspace have returned representations for basis vectors of the column space of A. Even though we know that when x has one spacific value, those spaces will have the wrong dimensions.
det(A)
ans =
27 - 3*x
solve(det(A) == 0)
ans =
9
Because when x==9, the matrix is now rank deficient, and therefore the various bases will have different dimensions. So be careful when applying all of these tools to general symbolic arrays.
Finally, see that when applied to symbolic arrays, the vectors will not always have unit norm. The symbolic toolbox seems to be a bit arbitrary here in the choice of vector normalizations.
A = sym(randi(5,3,4))
A =
[ 1, 1, 5, 1]
[ 2, 5, 1, 5]
[ 5, 3, 3, 1]
>> B = null(A)
B =
4/7
-17/14
-1/14
1
>> norm(B)
ans =
(98^(1/2)*275^(1/2))/98
So the null space vector did not have unit norm.
B = orth(A)
B =
[ 30^(1/2)/30, (2*15^(1/2)*187^(1/2))/2805, (19*2^(1/2)*187^(1/2))/374]
[ 30^(1/2)/15, (49*15^(1/2)*187^(1/2))/2805, -(2^(1/2)*187^(1/2))/187]
[ 30^(1/2)/6, -(4*15^(1/2)*187^(1/2))/561, -(3*2^(1/2)*187^(1/2))/374]
>> B'*B
ans =
[ 1, 0, 0]
[ 0, 1, 0]
[ 0, 0, 1]
Orth did yield results that were orthogonal, though it did not find as simple a result as colspace does next. Colspace may have decided that the matrix has rank 3, and therefore a good basis for the column space is just the 3x3 identity matrix.
B = colspace(A)
B =
[ 1, 0, 0]
[ 0, 1, 0]
[ 0, 0, 1]
I assume that colspace will be significantly faster than orth or null, when applied to symbolic arrays.
So probably more than you wanted to know about the various basis forming tools in MATLAB.
更多回答(1 个)
madhan ravi
2020-6-4
https://www.mathworks.com/help/symbolic/colspace.html - see bottom of the page for similar functionality functions.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!