Question

Create MATLAB code that will run statistics (min,max,mean,mode) on a selected column (just 1 column, not...

Create MATLAB code that will run statistics (min,max,mean,mode) on a selected column (just 1 column, not all of them). For example, if I want to run the statistics on the column 'age', it will only run it on that column and not the others. The file is cardio_dataset and each column is separated by commas.

The sample file is the following:

age,gender,height,weight,sys_bp,dia_bp,cholesterol_lvl,gluc_lvl,smoke,alco,active,cardio

50.3917808219178,2,168,62,110,80,1,1,0,0,1,0

55.4191780821918,1,156,85,140,90,3,1,0,0,1,1

51.6630136986301,1,165,64,130,70,3,1,0,0,0,1

48.2821917808219,2,169,82,150,100,1,1,0,0,1,1

47.8739726027397,1,156,56,100,60,1,1,0,0,0,0

60.0383561643836,1,151,67,120,80,2,2,0,0,0,0

60.5835616438356,1,157,93,130,80,3,1,0,0,1,0

61.8739726027397,2,178,95,130,90,3,3,0,0,1,1

48.4054794520548,1,158,71,110,70,1,1,0,0,1,0

Homework Answers

Answer #1
%matlab program
data = readtable('cardio_dataset.csv'); %read csv file
%choose column name to perform statistics operation
disp("1.age")
disp("2.gender")
disp("3.height")
disp("4.weight")
disp("5.sys_bp")
disp("6.dia_bp")
disp("7.cholesterol_lvl")
disp("8.gluc_lvl")
disp("9.smoke")
disp("10.alco")
disp("11.active")
disp("12.cardio")
choice  = input("Enter a column name to perfrom operations:");
%switch case will according to choice
switch choice
    case 1
        disp("age")
        Min = min(data.age)
        Max = max(data.age)
        Mean = mean(data.age)
        Mode =mode(data.age)
    case 2
        disp("gender")
        Min = min(data.gender)
        Max = max(data.gender)
        Mean=mean(data.gender)
        Mode=mode(data.gender)
    case 3
        disp("height")
        Min = min(data.height)
        Max = max(data.height)
        Mean= mean(data.height)
        Mode= mode(data.height)
    case 4
        disp("weight")
        Min=min(data.weight)
        Max=max(data.weight)
        Mean=mean(data.weight)
        Mode=mode(data.weight)
    case 5
        disp("sys_bp")
        Min=min(data.sys_bp)
        Max=max(data.sys_bp)
        Mean=mean(data.sys_bp)
        Mode=mode(data.sys_bp)
    case 6
        disp("dia_bp")
        Min=min(data.dia_bp)
        Max=max(data.dia_bp)
        Mean=mean(data.dia_bp)
        Mode=mode(data.dia_bp)
    case 7
        disp("cholesterol_lvl")
        Min=min(data.cholesterol_lvl)
        Max=max(data.cholesterol_lvl)
        Mean=mean(data.cholesterol_lvl)
        Mode=mode(data.cholesterol_lvl)
    case 8
        disp("gluc_lvl")
        Min=min(data.gluc_lvl)
        Max=max(data.gluc_lvl)
        Mean=mean(data.gluc_lvl)
        Mode=mode(data.gluc_lvl)
    case 9
        disp("smoke")
        Min=min(data.smoke)
        Max=max(data.smoke)
        Mean=mean(data.smoke)
        Mode=mode(data.smoke)
    case 10
        disp("alco")
        Min=min(data.alco)
        Max=max(data.alco)
        Mean=mean(data.alco)
        Mode=mode(data.alco)
    case 11
        disp("active")
        Min=min(data.active)
        Max=max(data.active)
        Mean=mean(data.active)
        Mode=mode(data.active)
    case 12
        disp("cardio")
        Min=min(data.cardio)
        Max=max(data.cardio)
        Mean=mean(data.cardio)
        Mode=mode(data.cardio)
    otherwise
        disp("Column is not present in the file")
 
end

Output::

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For this lab assignment you will need to write some code and create some graphs. You...
For this lab assignment you will need to write some code and create some graphs. You may use excel to create your graphs, or other language of your choice. Your data needs to demonstrate the experimental running time for Selection Sort (code in book), Merge Sort (code in book), and the Arrays.sort() method. Here is a basic outline of how you need to code this assignment. 1) Create several arrays of size 100, 1000, 10000, 100000, 1000000, … (you need...
TrackMinMax For this lab, you will create a generic version of the IntTrackMinMax class you wrote...
TrackMinMax For this lab, you will create a generic version of the IntTrackMinMax class you wrote in a previous lab, called TrackMinMax. The API is: Function Signature Description constructor TrackMinMax() constructor check void check(T i) compares i to the current minimum and maximum values and updates them accordingly getMin T getMin() returns the minimum value provided to check() so far getMax T getMax() returns the maximum value provided to check() so far toString String toString() returns the string "[min,max]" As...
Hello! I'm getting this assignment wrong according to the cengage software. The code looks right to...
Hello! I'm getting this assignment wrong according to the cengage software. The code looks right to me but apparently it is not. May someone please take a look at it and let me know what I'm doing wrong. I just can't seem to find the error. I'm attaching the question below and below that I will attach my code. I appreciate any help you could provide. The book is: HTML5, CSS3, and JavaScript, 6th edition, Bundle Thanks QUESTION: General Flex...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
Challenge 5 Read ALL of the instructions carefully before starting the exercise! Dear Colleague, Earlier today...
Challenge 5 Read ALL of the instructions carefully before starting the exercise! Dear Colleague, Earlier today I built my fourth website using HTML5 and CSS3. This time I wanted to try using CSS float layout options on a website dedicated to my favorite topic: robotics. I wanted my website to look like what is shown in Figure 1 (see below). However, after giving it my best effort, things once again didn’t turn out the way I wanted (see the code...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...