-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
240 additions
and
27 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/resources/templates/matlab/exercise/.gitattributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
* text=auto | ||
|
||
*.fig binary | ||
*.mat binary | ||
*.mdl binary diff merge=mlAutoMerge | ||
*.mdlp binary | ||
*.mex* binary | ||
*.mlapp binary | ||
*.mldatx binary | ||
*.mlproj binary | ||
*.mlx binary | ||
*.p binary | ||
*.sfx binary | ||
*.sldd binary | ||
*.slreqx binary merge=mlAutoMerge | ||
*.slmx binary merge=mlAutoMerge | ||
*.sltx binary | ||
*.slxc binary | ||
*.slx binary merge=mlAutoMerge | ||
*.slxp binary | ||
|
||
## Other common binary file types | ||
*.docx binary | ||
*.exe binary | ||
*.jpg binary | ||
*.pdf binary | ||
*.png binary | ||
*.xlsx binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Autosave files | ||
*.asv | ||
*.m~ | ||
*.autosave | ||
*.slx.r* | ||
*.mdl.r* | ||
|
||
# Derived content-obscured files | ||
*.p | ||
|
||
# Compiled MEX files | ||
*.mex* | ||
|
||
# Packaged app and toolbox files | ||
*.mlappinstall | ||
*.mltbx | ||
|
||
# Deployable archives | ||
*.ctf | ||
|
||
# Generated helpsearch folders | ||
helpsearch*/ | ||
|
||
# Code generation folders | ||
slprj/ | ||
sccprj/ | ||
codegen/ | ||
|
||
# Cache files | ||
*.slxc | ||
|
||
# Cloud based storage dotfile | ||
.MATLABDriveTag | ||
|
||
# buildtool cache folder | ||
.buildtool/ |
3 changes: 3 additions & 0 deletions
3
src/main/resources/templates/matlab/exercise/averageGradeByStudent.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function avg = averageGradeByStudent(grades) | ||
% TODO: Task 2 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function g = finalGrade(grades,weights) | ||
% TODO: Task 3 | ||
end |
3 changes: 3 additions & 0 deletions
3
src/main/resources/templates/matlab/exercise/medianGradeByAssignment.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function avg = medianGradeByAssignment(grades) | ||
% TODO: Task 1 | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Grading Statistics | ||
|
||
In this exercise, you will analyze student performance based on a matrix of | ||
grades. Each row in the matrix represents a student, and each column represents | ||
an assignment. | ||
|
||
Your task is to implement three functions that compute statistical measures for | ||
this data. Each function has a specific purpose, described below: | ||
|
||
## Task 1: Median Grade by Assignment | ||
Compute the median grade for each assignment across all students. The result | ||
should be a row vector where each element corresponds to the median of a | ||
specific assignment (column). | ||
|
||
- **Function to Implement**: `medianGradeByAssignment()` | ||
- **Input**: A matrix `grades` where rows are students and columns are assignments. | ||
- **Output**: A row vector of medians, one for each assignment. | ||
|
||
[task][Median Grade by Assignment](testMedianGradeByAssignment) | ||
|
||
--- | ||
|
||
## Task 2: Average Grade by Student | ||
Calculate the arithmetic mean grade for each student across all their assignments. | ||
The result should be a row vector where each element corresponds to a student's | ||
arithmetic mean grade. | ||
|
||
- **Function to Implement**: `averageGradeByStudent()` | ||
- **Input**: A matrix `grades` where rows are students and columns are assignments. | ||
- **Output**: A row vector of averages, one for each student. | ||
|
||
[task][Average Grade by Student](testAverageGradeByStudent) | ||
|
||
--- | ||
|
||
## Task 3: Final Grade | ||
Determine the weighted final grade for each student. In addition to the | ||
`grades` matrix, you are provided with a row vector `weights` (summing to 1) | ||
that represents the weight of each assignment. Compute the weighted average for | ||
each student and round the result to 1 decimal place. The result should be a | ||
row vector where each element corresponds to a student’s final grade. | ||
|
||
- **Function to Implement**: `finalGrade()` | ||
- **Input**: | ||
1. A matrix `grades` where rows are students and columns are assignments. | ||
2. A row vector `weights` with the same number of elements as columns in the `grades` matrix. | ||
- **Output**: A row vector of weighted final grades, rounded to 1 decimal place. | ||
|
||
[task][Final Grade](testFinalGrade) |
28 changes: 28 additions & 0 deletions
28
src/main/resources/templates/matlab/solution/.gitattributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
* text=auto | ||
|
||
*.fig binary | ||
*.mat binary | ||
*.mdl binary diff merge=mlAutoMerge | ||
*.mdlp binary | ||
*.mex* binary | ||
*.mlapp binary | ||
*.mldatx binary | ||
*.mlproj binary | ||
*.mlx binary | ||
*.p binary | ||
*.sfx binary | ||
*.sldd binary | ||
*.slreqx binary merge=mlAutoMerge | ||
*.slmx binary merge=mlAutoMerge | ||
*.sltx binary | ||
*.slxc binary | ||
*.slx binary merge=mlAutoMerge | ||
*.slxp binary | ||
|
||
## Other common binary file types | ||
*.docx binary | ||
*.exe binary | ||
*.jpg binary | ||
*.pdf binary | ||
*.png binary | ||
*.xlsx binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Autosave files | ||
*.asv | ||
*.m~ | ||
*.autosave | ||
*.slx.r* | ||
*.mdl.r* | ||
|
||
# Derived content-obscured files | ||
*.p | ||
|
||
# Compiled MEX files | ||
*.mex* | ||
|
||
# Packaged app and toolbox files | ||
*.mlappinstall | ||
*.mltbx | ||
|
||
# Deployable archives | ||
*.ctf | ||
|
||
# Generated helpsearch folders | ||
helpsearch*/ | ||
|
||
# Code generation folders | ||
slprj/ | ||
sccprj/ | ||
codegen/ | ||
|
||
# Cache files | ||
*.slxc | ||
|
||
# Cloud based storage dotfile | ||
.MATLABDriveTag | ||
|
||
# buildtool cache folder | ||
.buildtool/ |
3 changes: 3 additions & 0 deletions
3
src/main/resources/templates/matlab/solution/averageGradeByStudent.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function avg = averageGradeByStudent(grades) | ||
avg = mean(grades,2).'; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function g = finalGrade(grades,weights) | ||
g = round((grades * weights.').',1); | ||
end |
3 changes: 3 additions & 0 deletions
3
src/main/resources/templates/matlab/solution/medianGradeByAssignment.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function avg = medianGradeByAssignment(grades) | ||
avg = median(grades); | ||
end |
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/main/resources/templates/matlab/test/tests/GradeTest.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
classdef GradeTest < matlab.unittest.TestCase | ||
properties | ||
grades | ||
end | ||
|
||
methods (TestClassSetup) | ||
% Shared setup for the entire test class | ||
end | ||
|
||
methods (TestMethodSetup) | ||
% Setup for each test | ||
|
||
function setupGrades(testCase) | ||
testCase.grades = [1.3 3.3 4.0 4.7 | ||
2.7 1.7 4.0 1.7 | ||
1.7 3.7 3.0 4.3 | ||
4.3 2.3 1.7 3.3 | ||
2.3 3.7 2.0 5.0]; | ||
end | ||
end | ||
|
||
methods (Test) | ||
% Test methods | ||
|
||
function testMedianGradeByAssignment(testCase) | ||
actual = medianGradeByAssignment(testCase.grades); | ||
expected = [2.3 3.3 3.0 4.3]; | ||
testCase.assertEqual(actual,expected,"median is incorrect",AbsTol=0.0001); | ||
end | ||
|
||
function testAverageGradeByStudent(testCase) | ||
actual = averageGradeByStudent(testCase.grades); | ||
expected = [3.325 2.525 3.175 2.9 3.25]; | ||
testCase.assertEqual(actual,expected,"average is incorrect",AbsTol=0.0001); | ||
end | ||
|
||
function testFinalGrade(testCase) | ||
weights = [0.1 0.1 0.5 0.3]; | ||
actual = finalGrade(testCase.grades,weights); | ||
expected = [3.9 3.0 3.3 2.5 3.1]; | ||
testCase.assertEqual(actual,expected,"final grades are incorrect",AbsTol=0.0001); | ||
end | ||
end | ||
|
||
end |
This file was deleted.
Oops, something went wrong.