Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Matlab script that will create a structure using the struct command. Th

ID: 3863359 • Letter: C

Question

Create a Matlab script that will create a structure using the struct command. The structure should have 3 fields corresponding to name, grade level, and GPA. Using a loop, populate the structure with data from the table below. Your code should also calculate the number of students and the average GPA, median GPA, standard deviation GPA, and the Interquartile range of the GPA. Your code should produce a box-whisker plot of the GPAs for each grade level. Be sure to save your table data for use in problem 3.

Explanation / Answer

matlab code:

clear all; close all;
table = [];
s = struct('name','Mullins' ,'grade' , 12, 'GPA', 2.2821 );table = [table;s];
s = struct('name','Benson' ,'grade' , 12, 'GPA', 3.3362 );table = [table;s];
s = struct('name','Sanford' ,'grade' , 9 ,'GPA',2.6448 );table = [table;s];
s = struct('name','Moss' ,'grade' , 12, 'GPA', 3.04);table = [table;s];
s = struct('name','Harington' ,'grade', 11, 'GPA',2.7822 );table = [table;s];

s = struct('name','Sympson' ,'grade' , 9, 'GPA', 3.1214);table = [table;s];
s = struct('name','Doyle' ,'grade' , 10, 'GPA', 2.7599 );table = [table;s];
s = struct('name','Write' ,'grade' , 11, 'GPA', 3.196 );table = [table;s];
s = struct('name','Peterson' ,'grade' , 12, 'GPA', 3.2957);table = [table;s];
s = struct('name','Soloman' ,'grade' , 12, 'GPA', 3.6848);table = [table;s];

s = struct('name','wit' ,'grade' , 9, 'GPA',2.9224 );table = [table;s];
s = struct('name','Grant' ,'grade' , 12, 'GPA', 2.1447);table = [table;s];
s = struct('name','Hendricks' ,'grade' , 12, 'GPA', 2.6642 );table = [table;s];
s = struct('name','Jones' ,'grade' , 10, 'GPA', 3.5418 );table = [table;s];
s = struct('name','Dunlaps' ,'grade' ,12 , 'GPA', 2.5711 );table = [table;s];

s = struct('name','Byers' ,'grade' , 9, 'GPA',3.3844 );table = [table;s];
s = struct('name','fuentes' ,'grade' , 10, 'GPA', 3.0496 );table = [table;s];
s = struct('name','Nicholson' ,'grade' , 12, 'GPA',3.5747 );table = [table;s];
s = struct('name','Norman' ,'grade' , 12, 'GPA', 2.2156 );table = [table;s];
s = struct('name','Patterson' ,'grade' , 12, 'GPA', 2.9209 );table = [table;s];
number_of_students = size(table,1)
Average_gpa = sum([table.GPA])/number_of_students
MEDIAN_GPA = median([table.GPA])
STD_gpa = std([table.GPA])
interquartile_range = iqr([table.GPA])
boxplot([table.GPA])
xlabel('grade')
ylabel('gpa')