Filter löschen
Filter löschen

How can I produce a matrix with below condition?

1 Ansicht (letzte 30 Tage)
S AsZ
S AsZ am 10 Nov. 2023
Kommentiert: Voss am 10 Nov. 2023
Hi everyone.I need to produce a k×1 matrix that its first element always is 1 and the others return a random number in [0,1].This interval contains 0 and 1 and all values between them.

Akzeptierte Antwort

Voss
Voss am 10 Nov. 2023
Something like this may be good enough:
k = 8;
result = [1; rand(k-1,1)]
result = 8×1
1.0000 0.2558 0.8030 0.3604 0.5523 0.6364 0.1631 0.6867

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by