Question

In: Computer Science

Given the following two matrices: Matrix A that contains the marks of the college of engineering...

  1. Given the following two matrices:
  • Matrix A that contains the marks of the college of engineering students (250 Student) in 12 courses
  • Matrix B that contains the number of credit hours of each course.

Write a Matlab code to

  1. Print the letter grades (A to D) of student if you are given his ID and the course number from 1 to 12
  2. Print his GPA in this semester.

Gpa=sum(mark in subject i * subiect credit i) /total number of credit,
i=1:12

Solutions

Expert Solution

MATLAB:


clc;close all;clear all;
A = randi([10,100],250,12);
B = randi([2,6],1,12);
i=input('Enter student id:?');
j=input('Enter course number:?');
%TO define grades

if A(i,j)>= 91 && A(i,j)>=100
grade='A';
elseif A(i,j) >= 81 && A(i,j)>=90
grade='B';
elseif A(i,j) >= 71 && A(i,j)>=80
grade='C';
elseif A(i,j) >= 61 && A(i,j)>=70
grade='D';
elseif A(i,j) <61
grade='F';
end
fprintf('The grade of the student in the subject is %c\n',grade);
%To calculate GPA of the semester
for j=1:1:12
Gpa=Gpa+(A(i,j) * B(j) );
endfor
Gpa=Gpa/(10*sum(B));
fprintf('The GPA of the student in this semester is %3.2f\n',Gpa);

Command window:

Enter student id:?100
Enter course number:?10
The grade of the student in the subject is F
The GPA of the student in this semester is 5.14

Enter student id:?200
Enter course number:?12
The grade of the student in the subject is F
The GPA of the student in this semester is 6.84

Enter student id:?150
Enter course number:?11
The grade of the student in the subject is F
The GPA of the student in this semester is 4.97


Related Solutions

Divide and Conquer (Strassen’s Matrix Multiplication) Given two square matrices A and B of size n...
Divide and Conquer (Strassen’s Matrix Multiplication) Given two square matrices A and B of size n x n each, find their multiplication matrix. Naive Method Following is a simple way to multiply two matrices.                void multiply(int A[][N], int B[][N], int C[][N]) {     for (int i = 0;   i < N; i++) {         for (int j = 0; j < N; j++) {             C[i][j] = 0;             for (int k = 0; k < N; k++) {                 C[i][j] += A[i][k]*B[k][j];             }...
The following algorithm multiplies two square matrices using a straightforward implementation of the definition of matrix...
The following algorithm multiplies two square matrices using a straightforward implementation of the definition of matrix multiplication. (If you are unfamiliar with matrices, think of them as 2-dimensional arrays, and don’t worry, you don’t need to know how to do matrix multiplication to solve this problem) 1 2 3 4 5 6 7 8 9 10 ALGORITHM MatrixMultiplication(A[1..n, 1..n], B[1..n, 1..n]) // Multiply two square matrices of order n using the definition-based algorithm //Input: twon×nmatricesAandB // Output: matrix C =...
For the following matrices, first find a basis for the column space of the matrix. Then...
For the following matrices, first find a basis for the column space of the matrix. Then use the Gram-Schmidt process to find an orthogonal basis for the column space. Finally, scale the vectors of the orthogonal basis to find an orthonormal basis for the column space. (a) [1 1 1, 1 0 2, 3 1 0, 0 0 4 ] b) [?1 6 6, 3 ?8 3, 1 ?2 6, 1 ?4 ?3 ]
What is the difference between multiplying a matrix times a vector and multiplying two matrices?
What is the difference between multiplying a matrix times a vector and multiplying two matrices?
In Java Describe an algorithm that given a matrix described below determines whether matrix contains a...
In Java Describe an algorithm that given a matrix described below determines whether matrix contains a value k. The input matrix A[1...n, 1...n] has all rows and columns arranged in an non-descending order A[i, j] < A[i, j+1], A[j, i] < A[j + 1, i] for all 1 < i < n and 1 < j < n
BCG growth matrix , Ansoff matrix and resource based variables Many tools, such as various matrices,...
BCG growth matrix , Ansoff matrix and resource based variables Many tools, such as various matrices, can be used by a company performing strategic analysis. Pick any three tools and briefly describe each and explain when a company could use them. What are their limitations? Use examples to illustrate the use of your three chosen tools. Critically analyse and elaborate
For matrices, a mulitplicative identity is a square matrix X such XA = AX = A...
For matrices, a mulitplicative identity is a square matrix X such XA = AX = A for any square matrix A. Prove that X must be the identity matrix. Prove that for any invertible matrix A, the inverse matrix must be unique. Hint: Assume that there are two inverses and then show that they much in fact be the same matrix. Prove Theorem which shows that Gauss-Jordan Elimination produces the inverse matrix for any invertible matrix A. Your proof cannot...
Given below is a correlation matrix from a study of drinking habits of college students.  The purpose...
Given below is a correlation matrix from a study of drinking habits of college students.  The purpose of the study is to examine what affects the amount of alcohol consumed by students. Consumption (C) has been measured as the amount of alcohol consumed per week.  Sports (S) refers to the amount of time spent by the student on sports and athletics activities per week. Consumption (H) at home refers to the amount of alcohol consumed by the student’s family at home per...
You are given a text file that contains the timetable for buses that travel a college...
You are given a text file that contains the timetable for buses that travel a college campus. The first line of the file contains the name for each stop on the bus system separated by colons. Each following line contains the times using a 24-hour clock at which each bus in the system will arrive at a bus stop, also separated by colons.The timetable will have the following format: Edinburgh:Danderhall:Dalkeith:Edgehead:Pathhead:Blackshiels:Oxton:Carfraemill:Lauder:Earlston:Leaderfoot:Newtown St Boswells:St Boswells:Clintmains:Kelso 0850:0911:0918:0930:0933:0939:0953:0955:1001:1015:1025:1029:1032:1038:1055 1150:1211:1218:1230:1233:1239:1253:1255:1301:1315:1325:1329:1332:1338:1355 1350:1411:1418:1430:1433:1439:1453:1455:1501:1515:1525:1529:1532:1538:1555 1610:1633:1640:1652:1655:1701:1715:1717:1723:1737:1746:1750:1753:1803:1820 1750:1811:1818:1830:1833:1839:1853:1855:1901:1919:1925:1929:1932:1938:1955 2000:2021:2028:2037:2040:2046:2100:2102:2108:2121:2126:2130:2133:2138:2155 Write...
Given the following Matrices: Briefly discuss the importance of studying mathematical economics
Given the following Matrices: Briefly discuss the importance of studying mathematical economics
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT