Write a MATLAB function (testLucky.m) 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...


Write a MATLAB function (testLucky.m) 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>Author: your_name<br>» testlucky(5)<br>ans =<br>logical<br>» testlucky(6)<br>ans -<br>logical<br>Hint: To get a logical 1 and logical 0 as output of your function, see

Extracted text: Write a MATLAB function (testLucky.m) 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 Author: your_name » testlucky(5) ans = logical » testlucky(6) ans - logical Hint: To get a logical 1 and logical 0 as output of your function, see "help true" and "help false".

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here