gpa calculator with matrix
Show older comments
I want to make n by 2 matrix and put the grades for first column and second one fore the units (credits) of the grades and then ask to take the numbers from the user and then clculate the gpa
I tried such an script :
and I don't know what to do any more
I will be so thankful if someone help me
% matrix as a gpa calculator
n = input ('"n" value =') , % n is the number of lessons and grades ???????
Answers (1)
David Hill
on 18 Mar 2021
Why not just input the matrix?
m=input('matrix of grades and units, for example [3.5,4;2.7,2;4.0,3;3.3,2]');
gpa=sum(prod(m,2))/sum(m(:,2));
4 Comments
Milad Houshmand
on 18 Mar 2021
Edited: Milad Houshmand
on 18 Mar 2021
David Hill
on 18 Mar 2021
You have to enter the matrix correctly. If you copy and past the example, you should not get an error.
m=[3.5,4;2.7,2;4.0,3;3.3,2];
m =
3.5000 4.0000
2.7000 2.0000
4.0000 3.0000
3.3000 2.0000
Milad Houshmand
on 18 Mar 2021
David Hill
on 18 Mar 2021
Ok, make two inputs
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!