MATLAB Lecture #4 EGR 110 - Engineering Graphics
MATLAB Lecture #4 EGR 110 - Engineering Graphics
MATLAB Lecture #4 EGR 110 - Engineering Graphics
s
< s +
< s
<
=
x 20 , 0
20 x 10 , 80 x 4
10 x 0 x, 4
0 x , 0
y(x)
: follows as defined is y(x) Function
0
10
20
x
y
40
13
MATLAB Lecture #4 EGR 110 Engineering Graphics
% IF - THEN - ELSE structure - Example 4
% EGR 110
% filename: if4.m
% Sample program to display letter grade for an input
% numerical grade using a standard 10 point scale.
% Display error message if grades are from 0 to 100.
format compact
Grade = input('Enter numerical grade (0 to 100): ');
if Grade < 0 | Grade > 100
disp('Invalid grade')
elseif Grade >= 90
disp('Grade = A')
elseif Grade >= 80
disp('Grade = B')
elseif Grade >= 70
disp('Grade = C')
elseif Grade >= 60
disp('Grade = D')
else
disp('Grade = F')
end