Rank function returning two different values to the same matrix

5 views (last 30 days)
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.

Answers (1)

David Goodmanson
David Goodmanson on 23 Nov 2018
Edited: David Goodmanson on 24 Nov 2018
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.

Categories

Find more on Linear Algebra in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!