How do I create a column vector of random numbers between -40 and 40, with "n" entries?
22 ビュー (過去 30 日間)
古いコメントを表示
I know rand returns random values between 0 and 1 and randi returns random integers, but how do I create a column vector with random numbers within a certain range?
2 件のコメント
Amit A
2023 年 5 月 18 日
how to create a column vector named srcBits containing 20,000 randomly-generated bits.
Image Analyst
2023 年 5 月 18 日
@Amit A, start your own question in a new thread, and there say how many elements you want in the vector and how many bits are in each number/element of the vector.
回答 (2 件)
Star Strider
2016 年 10 月 26 日
If you want random floating-point numbers:
n = 1000; % Pick A Number
rv = 80*rand(n,1)-40; % Vector Of Random Floating-Point Numbers
figure(1)
hist(rv,50) % Check Result (Optional)
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!