Rank function returning two different values to the same matrix
5 次查看(过去 30 天)
显示 更早的评论
a=rank(rand(100,24))
b=rank(rand(100,1)*rand(1,24))
a=24
b=1
I just wonder why the value of b is 1 and not 24. Thanks in advance.
0 个评论
回答(1 个)
David Goodmanson
2018-11-23
编辑:David Goodmanson
2018-11-24
Hi Subash,
It's not the same construction process at all. Try it with smaller numbers, and integers:
m = 5;
n = 4;
A = randi(10,m,n)
b = randi(10,m,1)
c = randi(10,1,n)
B=b*c
A =
3 5 8 2
4 7 6 1
2 6 10 5
10 7 3 5
7 6 2 4
b =
8
7
8
10
10
c = 2 2 7 1
B =
16 16 56 8
14 14 49 7
16 16 56 8
20 20 70 10
20 20 70 10
matrix A is a set of random integers, and it so happens that its four rows are linearly independent, so rank = 4. (Usually, but not always, matrices with integer random number entries have the largest possible rank).
Matrix B is an outer product of a column vector and a row vector, and consequently all its rows are multiples of each other. (I picked an example where all rows are obvious integer multiples of row 4). There is only one independent column vector here, so the rank is 1.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!