Mat Lab Question
Mat Lab Question:
%% Q1 (60%)
% Follow the steps below to complete this question.
%
% Step 1: (40%)
% Create a function to perform calculations: +, -, *, or /
% 1.1 The function name should be calc and saved in its file.
% 1.2 The function has three parameters a, b, and op. The op isan
% operator. ÂÂ
% 1.3 The function returns variable r for the calculationresult.
% 1.4 The function should provide the following help text:
% \"The calc is a simple calculator. It has three parameters.
% The first two parameters are numerical operands, and the thirdone
% is an operator +, -, *, or / \"
% 1.5 Use the if conditional statement in the funciton to check theoperator op
% and compute accordingly.
% Note: Example about the syntax to check a single character: if(op== '+')
% Note: You can test the calc function in the Command Window usingthe syntax:
% >> calc(5, 3, '+')
% You can display the help text:
% >> help calc
%
% You can check if a division is divided by 0, but this is notrequired. Hint: use Inf or NaN
%
%% Q2 (15%)
% This question is similar to the requirement in Step 1 of Q1,except the
% following:
% Function name: calc_switch.m
% Here you want to use the switch statement instead of the ifstatement to check the operator.
% You are not required to do Steps 2-4 in Q1. But you can test thisfunction in the same way.