Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

mat lab hw i need a function first. the data given is given in one of the attachments Problem 3: Write a function lottery.m that

mat lab hw
i need a function first.
the data given is given in one of the attachments
image text in transcribed
image text in transcribed
image text in transcribed
Problem 3: Write a function lottery.m that checks for winning tickets and returns win- ning dollar amount. The function should have the following declaration: function amount lottery(ticket) where ticket is an input vector with 6 lottery numbers and the out- put amount denotes the winning amount. Download the file winning number.dat from CANVAS. The file includes 6 winning numbers. Load the file inside function lottery, i.e. load ('winning number.dat'), and use it to determine the winning dollar amount which depends on the matching between the numbers on the ticket and the winning numbers. Use the following formula: No match: amount =0 1 matching numbers: amount = 10 4 2 matching numbers: amount 100 3 matching numbers: amount = 1,000 4 matching numbers: amount = 10,000 5 matching numbers: amount = 1,000,000 6 matching numbers: amount = 100,000,000 Use if statement and function intersect to check for matching numbers. Remember to include a description for the function. Note that a different winning number.dat file will be used during grading. (a) Set p3a = evalc('help lottery'). (b) Set p3b= lottery ([2, 3, 4, 5, 6, 7]). (c) Set p3c= lottery ([12, 23, 24, 34, 50, 1]). (d) Set p3d= lottery ([22, 33, 44, 50, 51, 61]). (e) Set p3e lottery ([32, 43, 54, 44, 51, 61]). (f) Set p3f= lottery ([42, 53, 34, 44, 51, 61]). (g) Set p3g = lottery ([42, 23, 34, 44, 51, 61]). (h) Set p3h= lottery ([12, 23, 34, 44, 51, 61]). = 1.20000000+01 6.1000000e+01 2.3000000e+01 3.4e+01 4.4000000e+01 5.1000000e+01 Problem 3: Write a function lottery.m that checks for winning tickets and returns win- ning dollar amount. The function should have the following declaration: function amount lottery(ticket) where ticket is an input vector with 6 lottery numbers and the out- put amount denotes the winning amount. Download the file winning number.dat from CANVAS. The file includes 6 winning numbers. Load the file inside function lottery, i.e. load ('winning number.dat'), and use it to determine the winning dollar amount which depends on the matching between the numbers on the ticket and the winning numbers. Use the following formula: No match: amount =0 1 matching numbers: amount = 10 4 2 matching numbers: amount 100 3 matching numbers: amount = 1,000 4 matching numbers: amount = 10,000 5 matching numbers: amount = 1,000,000 6 matching numbers: amount = 100,000,000 Use if statement and function intersect to check for matching numbers. Remember to include a description for the function. Note that a different winning number.dat file will be used during grading. (a) Set p3a = evalc('help lottery'). (b) Set p3b= lottery ([2, 3, 4, 5, 6, 7]). (c) Set p3c= lottery ([12, 23, 24, 34, 50, 1]). (d) Set p3d= lottery ([22, 33, 44, 50, 51, 61]). (e) Set p3e lottery ([32, 43, 54, 44, 51, 61]). (f) Set p3f= lottery ([42, 53, 34, 44, 51, 61]). (g) Set p3g = lottery ([42, 23, 34, 44, 51, 61]). (h) Set p3h= lottery ([12, 23, 34, 44, 51, 61]). = 1.20000000+01 6.1000000e+01 2.3000000e+01 3.4e+01 4.4000000e+01 5.1000000e+01

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Public Finance In Theory And Practice

Authors: Richard Abel Musgrave, Peggy B. Muscrave

5th Edition

0070441278, 978-0070441279

More Books

Students also viewed these Finance questions