Recent content by samuel1994

  1. S

    User Defined Functions in MATLAB

    Thank you for you help. I figured out the problem. This was my final code: function av = GPA(g,h) for k = 1:length(g) if g(k) == 'A' g(k) = 4; elseif g(k) == 'B' g(k) = 3; elseif g(k) == 'C' g(k) = 2; elseif g(k) == 'D' g(k) = 1; elseif g(k)...
  2. S

    User Defined Functions in MATLAB

    function av = GPA(g,h) A = 4; B = 3; C = 3; D = 1; E = 0; av = sum(g)/sum(h) This is what I have. I know it's wrong, but I'm merely lost on how to convert the string into numbers.
  3. S

    User Defined Functions in MATLAB

    Homework Statement Write a user-defined function that calculates grade point average (GPA) on a scale of 0 to 4, where A = 4, B = 3, C = 3, D = 1, and E = 0. For the function name and arguments use av = GPA(g,h). The input argument g is a vector whose elements are letter grades A, B, C, D...
Back
Top