
212 Programming for Chemical Engineers
40 otherwise
41 disp(‘Choice unavailable’);
42 end
43 C
Line 2: The clear statement clears all existing arrays in the memory.
Lines 4 to 17: Utilize the
for loop statements to collect all values needed to
assign to
A and B arrays.
Lines 18 to 24: Display the selection menu using
disp().
Lines 27 to 42: Utilize the
switch statement to select a particular operation to
perform based on the input of the user.
Line 43: Displays the
C matrix in the Command Window.
CREATING FUNCTIONS
Like any programming language, MATLAB also allows the creation of functions
to supplement existing functions. These serve as additional ...