> help testLuckytestLucky(x) - determine whether x is a lucky numberreturn true (1) if x is a lucky numberreturn false (0) if x is not a lucky number>> testLucky(5)ans =logical1>>...


Write a MATLAB function<br>that takes a number as an input argument and<br>checks to see if the number is lucky. In the function, begin by defining a vector named secretLucky<br>with the values 19, 22, 5, 9, 11, 15, 21. These are secret lucky numbers.<br>Use a for-loop in the function to check, element-by-element, if the number passed in to the function is<br>in the secretLucky vector. If the number is found in secretLucky, return true (1). If the number is<br>not found in secretLucky, return false (0). Include help comments in the function.<br>Your testLucky function must behave as shown below: (user input is underlined)<br>>> help testLucky<br>testLucky(x) - determine whether x is a lucky number<br>return true (1) if x is a lucky number<br>return false (0) if x is not a lucky number<br>>> testLucky(5)<br>ans =<br>logical<br>1<br>>> testLucky(6)<br>ans =<br>logical<br>Hint: To get a logical 1 and logical 0 as output of your function, see > Enter an number in the range 0 to 25: 10 Sorry! 10 is not a lucky number >> Enter an number in the range 0 to 25: 33 Number out of range! >> "/>
Extracted text: Write a MATLAB function that takes a number as an input argument and checks to see if the number is lucky. In the function, begin by defining a vector named secretLucky with the values 19, 22, 5, 9, 11, 15, 21. These are secret lucky numbers. Use a for-loop in the function to check, element-by-element, if the number passed in to the function is in the secretLucky vector. If the number is found in secretLucky, return true (1). If the number is not found in secretLucky, return false (0). Include help comments in the function. Your testLucky function must behave as shown below: (user input is underlined) >> help testLucky testLucky(x) - determine whether x is a lucky number return true (1) if x is a lucky number return false (0) if x is not a lucky number >> testLucky(5) ans = logical 1 >> testLucky(6) ans = logical Hint: To get a logical 1 and logical 0 as output of your function, see "help true" and "help false". 1b: Write a MATLAB program that prompts the user to enter a number in the range 0 to 25. If the number entered is less than 0 or greater than 25, output an out-of-range message and terminate. If the number entered is in the required range, proceed to test the number using the testLucky function written in the last question. Inform the user if the number entered is lucky or not lucky. Three example runs of the program are shown below, with user input underlined. Your program should create output exactly as shown below for the three values entered. Of course, your program should accept any number as input. Enter an number in the range 0 to 25: 22 You win! 22 is a lucky number >> Enter an number in the range 0 to 25: 10 Sorry! 10 is not a lucky number >> Enter an number in the range 0 to 25: 33 Number out of range! >>
Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here