Random number vector with only two values
5 ビュー (過去 30 日間)
古いコメントを表示
採用された回答
Stephen23
2024 年 9 月 23 日
編集済み: Stephen23
2024 年 9 月 23 日
Indexing is a basic MATLAB superpower. You can easily use indexing to select from a vector of any values:
V = [0,pi];
W = V(randi(numel(V),1,10))
Multiplication also works for this special case with only two values, one of which is zero:
W = pi * randi([0,1],1,10)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!