How to do the following on MATLAB A college professor would like to compare how
ID: 2086439 • Letter: H
Question
How to do the following on MATLAB
A college professor would like to compare how students perform on a test she gives each year. The following is the first and second year data as follow: Year 1 Student 1 Student 2 Question 1 Question 2 Question 3 Question 4 10 8 10 10 Student 3 Student 4 Student 5 10 Year 2 Question 1 Question 2 Question 3 Question 4 Student1 10 Student 2 Student 3 Student 4 Student 5 10 10 Create a multidimensional array called data Using atestdata created in a. calculate the average score for each question using mean, for each year, and store the results in a 2x4 2D array avg Calculate the average score for each question for year 1 and 2, and store them to all_avg Extract the data for Question 3 for each year from testdata, and create a 5x2 array, question_3, and display the array question_3. a. testdata with two pages each stores first and second years' test b. c. d.Explanation / Answer
Code:-
clear all
clc
testdata = zeros(5,4,2);
year1= [3,6,4,10;5,8,6,10;4,9,5,10;6,4,7,9;3,5,8,10];
year2= [2,7,3,10;3,7,5,10;4,5,5,10;3,3,8,10;3,5,2,10];
testdata(:,:,1) = year1;
testdata(:,:,2) = year2;
avg = zeros(2,4);
avg(1,:) = mean(testdata(:,:,1));
avg(2,:) = mean(testdata(:,:,2));
all_avg = mean(avg);
question3 = reshape(testdata(:,3,:),5,2);
avg
all_avg
disp("question3= ")
disp(question3)
Output:-
avg =
4.2000 6.4000 6.0000 9.8000
3.0000 5.4000 4.6000 10.0000
all_avg =
3.6000 5.9000 5.3000 9.9000
question3=
4 3
6 5
5 5
7 8
8 2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.