フィルターのクリア

How can I pick random numbers in a matrix?

2 ビュー (過去 30 日間)
Matrix-Matlab
Matrix-Matlab 2016 年 5 月 7 日
コメント済み: Matrix-Matlab 2016 年 5 月 7 日
Hello,
I have this question that I dont know how to solve.
Generate the matrix “Customers” containing random values for the following variables. The matrix must contain 3000 people.
a. Gender. Must be either 1 or 0. 0 signifies that the person is female.
b. Age. Must be between 21 and 85.(I have tried using the same as randi(85,3000,21) but it gives me a matrix which is [3000,21] and i need it to be [3000,1] since there will only be 1 age per customer.
c. Insurance risk. Must be a value between 1 and 10. (This I have solved by using randi(10,3000,1))
Can anyone help me solve this please?
Thank you in advance
- Emil

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 5 月 7 日
Customers.Gender = randi([0,1],3000,1);
Customers.Age = randi([21,85],3000,1);
Customers.Insurance_risk = randi(10,3000,1);
  1 件のコメント
Matrix-Matlab
Matrix-Matlab 2016 年 5 月 7 日
Thank you for the quick reply.
Can you also help me with this: Create a plot that shows the distribution of the insurance risk for males. Because im not really sure how to do it.
Thanks

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by