ask about random matrix
조회 수: 16 (최근 30일)
이전 댓글 표시
I want to build a matrix with random elements, but the number of elements in each row equals one. Please help with the syntax.
댓글 수: 2
Fangjun Jiang
2024년 3월 18일
@susila bahri, Is it the number of non-zero element in each row is one, or the sum of each row equals one?
답변 (1개)
Voss
2024년 3월 18일
편집: Voss
2024년 3월 18일
% number of rows:
N = 8;
Here are some example random matrices where each row has one element, which is what you asked for:
rand(N,1) % elements drawn from the uniform distribution between 0 and 1
randn(N,1) % elements drawn from the standard normal distribution
randi([6,9],N,1) % uniformly distributed integers between 6 and 9
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!