I have an if-else if construct which gives me grades A, B, C, D, F depending on marks from 0-100.
if (mark > 100) | (mark < 0)
disp('Invalid mark');
return; % Exit from the program.
end % Of first if statement
if mark >= 80 % Mark is in range 80 - 100.
grade = 'A';
elseif mark >= 70 % Mark is in range 70 - 79.
grade = 'B';
elseif mark >= 60 % Mark is in range 60 - 69.
grade = 'C';
elseif mark >= 50 % Mark is in range 50 - 59.
grade = 'D'
else % Mark is in range 0 - 44.
grade = 'F';
end
disp(grade);
Now, I have a another long vector of numeric marks (from 0-100) of size Ax1 called 'marks'. I am not sure; how to input each of those numeric marks through this line of code to achieve an output vector of grades?
Aucun commentaire:
Enregistrer un commentaire