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

1. Create a function called IsLarger that takes in two variables: Outputs a 1 if

ID: 3755575 • Letter: 1

Question


1. Create a function called IsLarger that takes in two variables: Outputs a 1 if the first number is arger Outputs a 0 if the second number is larger · 2. Two six-sided dice are rolled. Adding the two dice together results in values ranging 2 to 12 Create a function called DiceProb . The input of this function will range from 2 to 12 . The output will calculate the probability of a two six- sided dice Check your answer against the following table http://alumnus.caltech.edu hint: remember that probability (true outcomes)/(total tries) 3. Create a function called ManyDice This function can have one to number of six-sided dice . The inputs will be the number of dice and the results of the expected dice . The output will be the probability

Explanation / Answer

If you post more than 1 question, as per chegg guidelines I have to solve only first question.

Ques 1.

--------------------------isLarger.m------------------------

% return 1 if a is larger

% return 0 if a is larger

function [val] = isLarger(a , b)

    % if first number is larger

    if a > b

       

        val = 1;

       

    % if second number is larger

    else

       

        val = 0;

       

    end

end

------------------------main.m----------------------

% get user input

a = input('Enter first number : ');

b = input('Enter second number : ');

val = isLarger( a , b );

fprintf('isLarger( %d , %d ) : %d ', a, b , val);

Sample output

Enter first number : 1
Enter second number : 2
isLarger( 1 , 2 ) : 0