ask about random matrix
17 次查看(过去 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!