Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MATLAB (25 points) UDF & if/else statement. Please write a User Defined Function (UDF) that has one input and no output. The input is a
MATLAB
(25 points) UDF \& if/else statement. Please write a User Defined Function (UDF) that has one input and no output. The input is a single scalar (integer). The function called "Evenorodd". The function doesn't have output argument but should display in a sentence if the input is (positive, negative or zero) and (even or odd) number: i.e. "23 is an odd and positive number". Use If/else statement in your function. (Note: You need to include two files: one for the UDF function, and one for the script with testing commands) i. (20 Points) Create a UDF called "Evenorodd". Few guidelines which you don't have to follow: - Syntax for function without output arguments n - You can use more than one if/else statements: L.e, one for the sign (positive or negative or zero) and another one for (even or odd). - You may use disp or frrintf or any other commands to display the sentence. - If you are to use rem function to judge if the number is even or odd, you may want to consider absolute value for negative inputs. ii. (5 Points) Show results on command window using your function, EvenorOdd, with three different inputs 0,13 , and -24. For example 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