Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is for MATLAB program, please help me with the codes. thank you. We have se

ID: 675264 • Letter: T

Question

this is for MATLAB program, please help me with the codes. thank you.

We have seen that we can generate a random number in the range [1,6] to represent the roll of a six sided die, by using: randi([1, 6], 1) Modify the Function file so that it: Takes three such die values as input Determines if those three die values constitute a Straight - they can be arranged to form a sequence of consecutive values Returns true if they constitute a Straight, and false if not. Create a Function file named Lab07 Right click Current Folder title of that window Select New File by moving mouse to that option Click on Script in the pop-up menu Type Driver07 in the highlight field and hit the enter key Double click the Driver07. m entry (that you just created) in the Current Folder window Modify the Script file so that it: Generates three random ''die'' values Determines if those three die values constitute a Straight by call your function Lab07 Displays the generated die values and the functions output in a reasonable report like format

Explanation / Answer

Use this function to check if the numbers are a Straight

function randi = randiConsecutive(n1, n2, n3)
if(n2=n1+1)
if(n3=n2+1)
  return true;
end
else
if(n1=n2+1)
if(n3=n1+1)
  return true;
end
else
if(n3=n1+1)
if(n1=n2+1)
  return true;
end
else return false;
end


Now, use the randi function three times, to have three random die values

x= randi([1,6],1)
y= randi([1,6],1)
z= randi([1,6],1)

Now call our function randiConsecutive
randiConsecutive(x,y,z)