Unformatted text preview: ned function ‘Num2Ltr’.
function
Ink or screen grab your code here: LECTURE
Engineering
Engineering
Education function [ LetterGrade] = Num2Ltr( numgrade )
% Num2Ltr function which converts a numeric grade to a %
letter grade
% Only converts to A,B,C,D,F. If an invalid grade
%
is entered the function returns the letter 'X'.
if numgrade<0 || numgrade>100
LetterGrade='X';
elseif numgrade>=90
LetterGrade='A';
elseif numgrade>=80
LetterGrade='B';
elseif numgrade>=70
LetterGrade='C';
elseif numgrade>=60
LetterGrade='D';
else
LetterGrade='F';
end
end % extra end rarely needed in MATLAB functions Run your function for the following grades:
89.99, 103, 72 Note that NONE of the variable names used by the
function (internally) appear in your workspace.
This is because those variables are LOCAL to the
function. Values are passed to- and from- the
function via their positions in the argument lists. LECTURE
Engineering
Engineering
Education LECTURE
Engineering
Engineering
Education On your own…..try adding an ‘averaging algorithm’
to the max/min program to find the average of the
numbers entered……… LECTURE
Engineering
Engineering
Education...
View
Full Document
- Spring '06
- TWKnott
- Integers, Max, Prime number
-
Click to edit the document details