フィルターのクリア

How to plot a matrix with a column matrix

3 ビュー (過去 30 日間)
Matrix-Matlab
Matrix-Matlab 2016 年 5 月 8 日
コメント済み: Walter Roberson 2016 年 6 月 21 日
Hello,
I have an assignment which i dont understand how to fix.
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.
c. Insurance risk. Must be a value between 1 and 10.
2. Create a plot that shows the distribution of the insurance risk for males
3. Create a plot that shows the distribution of males and females
I have completed all the above and gotten the distribution of both males and females:
Males: 1496 and female 1504.
But i dont know how to plot these to show the distribution.
Can anyone help me?
Thank you in advance.
  4 件のコメント
Matrix-Matlab
Matrix-Matlab 2016 年 5 月 8 日
Okay I managed to solve it on my own

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

回答 (1 件)

Image Analyst
Image Analyst 2016 年 5 月 8 日
Assuming Customers is a structure array (could also be a table though), you could do this
% Extract all risks, regardless of gender, into one array:
allRisks = [Customers.insuranceRisk];
% Show the distribution in the current axes, creating one if one does not exist already:
histogram(allRisks);

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by