Answered step by step
Verified Expert Solution
Question
1 Approved Answer
clc clear strLineStyles = {'--b', ':b', '-k', '--k', ':g', '--g', '.g', '-g', '-r'}; for n=1:9 dataN = csvread('DataClass.csv'); colData = dataN(:, n); x=sort(colData); hold on
clc
clear
strLineStyles = {'--b', ':b', '-k', '--k', ':g', '--g', '.g', '-g', '-r'};
for n=1:9
dataN = csvread('DataClass.csv');
colData = dataN(:, n);
x=sort(colData);
hold on
plot(x,strLineStyles{n}) ;
end
plot([0, 250],[70, 70], '-r' )
plot([0, 250],[80, 80], '-r' )
plot([0, 250],[90, 90], '-r' )
xlabel('students numbers')
ylabel('Score (from 100)')
title('ENGR 112 scores')
legend('LabQuiz','zyBooks','Labs','Homeworks','Mid I','Mid II','Final','Exam Average','Grade')
Step by Step Instructions:+ Start a new script* Copy the first few lines from your Lab 1 problem (reading dataN and the strColumns) As in problem 1 you'll need a for loop over each column. You can either copy your for loop from problem 1 or just re-type it+ o o Printing out the means of each column* . o There are two ways to do this: -One is to call mean with the entire matrix (refer to help on mean to see what will happen when you do this)+ Use the colon operator to get out all of the elements for the column IN the for loop and then call mean on that (column) array.* * data(:1) returns all the data from column 1+ Either way you'll need a for loop that goes over each column (use size(0 command)+ o - Use strColumns to print out the name of the column along with the mean o Note: The first method is more efficient. Counting students+ First thing to do is declare an index variable for each of the columns you're interested in; that way, if they change later you don't have to re-write your code. Also makes it easier to read the code. Declare these before the for loop o " indexLabColumn 3; o Create a for loop that goes over each STUDENT this time (i.e., number of rows...) o Make a counting variable, eg, betterLabThanHomework - 0; - Again, this goes before the for loop starts+* Do just the homework score better than the lab score first. Hint: You'll need an if statement in the for loop o If you're struggling with either how to write the if or how to increment the counter variable, grab a TA* o Add another if statement for the homeworks and exams o Overall this should look like:+ Set the counting and index variables+ * for number of students if student's lab score is bigger than their homework score+ o Add one to the betterLabThanHomework score . if Print out the counting variables+ " Extra credit l This should look like mean(lab-homework )- how do you get out ALL of the student lab scores all at once? Hint: colon operator homework)- and like extra credit I you want to perform the comparison on ALL of the students all at once (not using a for loop) - lab > homework will return an ARRAY of zeros and ones, zeros for false, o ones for true. Then just count the ones...- Self-check: - Average 82.X4 for item LabQuiz* Average 135.x2 for item zyBooks Average 93.X0 for item Labs Average 91.X9 for item Homeworks Average 80.x1 for item MidtermL Average 75.X9 for item MidtermI Average 65.X6 for item Final Average 73.x9 for item ExamAvexage Average 86.X4 for item Grade Number of people with lab scores higher than honeworks: 1X5 Average difference: 1.x0 Number of people with homework scores higher than final exam: 2X5 Average difference: 25.X3 Total number of students: 2x9 Step by Step Instructions:+ Start a new script* Copy the first few lines from your Lab 1 problem (reading dataN and the strColumns) As in problem 1 you'll need a for loop over each column. You can either copy your for loop from problem 1 or just re-type it+ o o Printing out the means of each column* . o There are two ways to do this: -One is to call mean with the entire matrix (refer to help on mean to see what will happen when you do this)+ Use the colon operator to get out all of the elements for the column IN the for loop and then call mean on that (column) array.* * data(:1) returns all the data from column 1+ Either way you'll need a for loop that goes over each column (use size(0 command)+ o - Use strColumns to print out the name of the column along with the mean o Note: The first method is more efficient. Counting students+ First thing to do is declare an index variable for each of the columns you're interested in; that way, if they change later you don't have to re-write your code. Also makes it easier to read the code. Declare these before the for loop o " indexLabColumn 3; o Create a for loop that goes over each STUDENT this time (i.e., number of rows...) o Make a counting variable, eg, betterLabThanHomework - 0; - Again, this goes before the for loop starts+* Do just the homework score better than the lab score first. Hint: You'll need an if statement in the for loop o If you're struggling with either how to write the if or how to increment the counter variable, grab a TA* o Add another if statement for the homeworks and exams o Overall this should look like:+ Set the counting and index variables+ * for number of students if student's lab score is bigger than their homework score+ o Add one to the betterLabThanHomework score . if Print out the counting variables+ " Extra credit l This should look like mean(lab-homework )- how do you get out ALL of the student lab scores all at once? Hint: colon operator homework)- and like extra credit I you want to perform the comparison on ALL of the students all at once (not using a for loop) - lab > homework will return an ARRAY of zeros and ones, zeros for false, o ones for true. Then just count the ones...- Self-check: - Average 82.X4 for item LabQuiz* Average 135.x2 for item zyBooks Average 93.X0 for item Labs Average 91.X9 for item Homeworks Average 80.x1 for item MidtermL Average 75.X9 for item MidtermI Average 65.X6 for item Final Average 73.x9 for item ExamAvexage Average 86.X4 for item Grade Number of people with lab scores higher than honeworks: 1X5 Average difference: 1.x0 Number of people with homework scores higher than final exam: 2X5 Average difference: 25.X3 Total number of students: 2x9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started