Mat Lab Question Mat Lab Question: %% Q1 (60%) % Follow the steps below to complete this question. % %...

80.2K

Verified Solution

Question

Mechanical Engineering

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.

Answer & Explanation Solved by verified expert
3.9 Ratings (633 Votes)
Answer to question 1 CODE function rcalcabop displayThe calc is a simple calculator It has three parameters displayThe first two parameters are numerical operands and the third one is an operator if op    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students