How to write a function with 3 inputs and a calculated if statement?

I am currently stuck on this question and would greatly appreciate the help of how or where I should start.
Create a function that evaluates whether or not the height of a machined part is within the manufacturer's tolerance (i.e. the acceptable manufacturing limits). The function will take three input arguments--the specified value for the height, the actual value of the height, and the tolerance (how much the actual value can be over or under the specified value for the height). If your object is within the tolerance, you should display, "Within tolerance!", and if it is not, you should display, "Not within specified tolerance. Create a new part." Test your function for a specified height of 2 meters, an actual value of 1.995 meters, and a tolerance of 0.002 meters.

답변 (1개)

KSSV
KSSV 2021년 2월 1일
If a, b is your original and approximate values, tol is tolerance. You have to use:
if abs(a-b)<=tol
Next, read about how to create a funcition, if, fprintf.

카테고리

질문:

2021년 2월 1일

답변:

2021년 2월 1일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by