필터 지우기
필터 지우기

How can I produce a matrix with below condition?

조회 수: 1 (최근 30일)
S AsZ
S AsZ 2023년 11월 10일
댓글: Voss 2023년 11월 10일
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.

채택된 답변

Voss
Voss 2023년 11월 10일
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
  댓글 수: 2
S AsZ
S AsZ 2023년 11월 10일
Thanks 🌹
Voss
Voss 2023년 11월 10일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by