How to create a random matrix?

I am creating a SVD matrix UEV*. For that I want to create an E matrix with diagonal enteries in the range of [0,1] and also in increasing order. Can someone kindly suggest me a way to do so!

回答 (1 件)

John D'Errico
John D'Errico 2022 年 10 月 6 日
編集済み: John D'Errico 2022 年 10 月 6 日

0 投票

Can you generate a vector of numbers that all lie in the interval [0,1]? (I hope so. read the help for rand.)
Can you insure that vector of numbers lie in increasing order? (Again, I hope so. help sort)
Can you create a diagonal matrix, given a vector? (Again, help diag.)
The point is, when you have a problem that is too big for you to chew on, then break it down into smaller problems. Eat a programming elephant (even a small one) one byte at a time.

4 件のコメント

Anshuman
Anshuman 2022 年 10 月 6 日
Great approach! Thanks a lot!
Anshuman
Anshuman 2022 年 10 月 6 日
I am finding this dissambiguity in answers on taking the (.*) relation or not takin it with the product (*) why this happens?
U = rand(50);
V = rand(50);
d = rand(50,1);
s = sort(d);
e = diag(s);
A1 = U*e*(V)';
A2 = U.*e*(V)';
A3 = U.*e.*(V)';
Torsten
Torsten 2022 年 10 月 6 日
編集済み: Torsten 2022 年 10 月 6 日
All multiplications are pure matrix multiplications *. No room for elementwise multiplication .*
Anshuman
Anshuman 2022 年 10 月 7 日
Okay thanks for te definitions! Great!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2022 年 10 月 6 日

コメント済み:

2022 年 10 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by