Random number generator with max and min values included in the matrix

2 ビュー (過去 30 日間)
Khalid Sherif
Khalid Sherif 2020 年 11 月 21 日
コメント済み: Khalid Sherif 2020 年 11 月 22 日
I would like to know how to add minimum and maximum values to a matrix of random generated numbers but I am unable to find anything abou that.
This is the code I am using
xmin=mel2; %mel2 is 401.97
xmax=mel; % mel is 4.6871e+03
n=25; % number of random generated values in the matrix
x=sort(xmin+rand(1,n)'*(xmax-xmin));

回答 (1 件)

Matt J
Matt J 2020 年 11 月 22 日
I believe your code already works as written. Problem solved?
  1 件のコメント
Khalid Sherif
Khalid Sherif 2020 年 11 月 22 日
Well, it is correct but what I want is generate random numbers as well as to include the minimum and maximum values to the matrix, like linspace for example.
Anyway I used linspace and I am ok with it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by