How to get 10000 variable numbers between the range of 0 and 100?
4 ビュー (過去 30 日間)
古いコメントを表示
i want a variable array of 10000 numbers from 0 to 100.
a = -5; b = 5; varx = a + (b-a).*rand(10000,1); varX = 10.^varx;
so i want this in the above format.
can you help me out?
4 件のコメント
採用された回答
Star Strider
2022 年 8 月 27 日
編集済み: Star Strider
2022 年 8 月 28 日
If you want the numers to be between
and
, use the logspace function, then use randperm to randomise them —
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1109760/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1109765/image.png)
varx = logspace(-5, 5, 1E+5) % Generate Vector
varx = varx(randperm(numel(varx))) % Randomize It
Check = [min(varx) max(varx)] % Check Result
log10Check = log10(Check) % Verify
EDIT — (28 Aug 2022 at 2:16)
‘actually i want the values between 10^(-5) and 10^2.’
varx = logspace(-5, 2, 1E+5) % Generate Vector
varx = varx(randperm(numel(varx))) % Randomize It
Check = [min(varx) max(varx)] % Check Result
log10Check = log10(Check) % Verify
.
0 件のコメント
その他の回答 (1 件)
Abderrahim. B
2022 年 8 月 27 日
移動済み: Image Analyst
2022 年 8 月 27 日
Try this --
varx = 100*rand(10000, 1) ;
min(varx)
max(varx)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!