Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 3: User-defined functions (19 points) Create a function which returns the factorial, x! of the input argument, x. You need to create a UDF
Part 3: User-defined functions (19 points) Create a function which returns the factorial, x! of the input argument, x. You need to create a UDF to perform the task. The function should return the factorial of the input argument when it is a non-negative integer, 0, 1, 2,.... On the other side, the function must call the intrinsic MATLAB function error ) when the input argument is non-integer or negative; an appropriate error message should be displayed to the user. Read the help topics of the error function in MATLAB. Your function must have "help topics" and the "H1 line" (see course notes). When complete, test your function from the command line. EAS 230 Fall 2018 - Lab 7 - Page 2 NAME: PERSON #: LAB SECTION: Before you begin writing your function, take some time to answer these questions. Al answers should be written in the appropriate space in the table on the last page. (2 pts) What is the name of your function going to be? NOTE: The rules for naming functions are the same as naming scripts and variables in MATLAB. NOTE: the function name must not be the same as the intrinsic MATLAB function, factorial (). When you attempt to save the function, does MATLAB offer a default filename? 1. 2. (2 pts) What type(s) of programming structures do you expect to use, e.g., loops, branches, etc.? Answer these yes or no questions: 3. a. (1 pt) Do the variable names/mathematical expressions used when calling the function need to match the variable names used within the function? b. (1 pt) Do the variables created/modified within the function appear in your workspace
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started