Question: File 1: main.m repeat_process = 1 ; while repeat_process data1 = []; data2 = []; random_choice = randi( [0 1], 1, 1); if random_choice data1

 File 1: main.m repeat_process = 1; while repeat_process data1 = [];

File 1:

main.m

repeat_process = 1;

while repeat_process

data1 = [];

data2 = [];

random_choice = randi( [0 1], 1, 1);

if random_choice

data1 = randi ( [0 100], 1, 1 );

data2 = randi ( [0 100], 1, 1 );

else

data1 = randi ( [0 100], 10, 10 );

data2 = randi ( [0 100], 10, 10 );

end

user_operation_choice = input('Please select one of the following options: 1) Addition 2) Subtraction ');

do_math(random_choice, user_operation_choice, data1, data2);

repeat_process = input('Enter 1 to repeat. ');

end

File 2:

do_math.m

function do_math (math_type, user_operation_choice, data1, data2)

result = 0;

if math_type

switch user_operation_choice

case 1

result = add_numbers(data1, data2);

case 2

result = subtract_numbers(data1, data2);

end %end switch statement

else

do_math_arrays(user_operation_choice, data1, data2);

return;

end %end if-else statement

disp(result);

end %end function do_math

function n_sum = add_numbers(data1, data2);

n_sum = data1 + data2;

end %end function add_numbers

function n_sub = subtract_numbers(data1, data2);

n_sub = data1 - data2;

end %end function add_numbers

File 3:

do_math_arrays.m

function do_math_arrays (user_operation_choice, data1, data2)

result = 0;

switch user_operation_choice

case 1

result = add_numbers(data1, data2)

case 2

result = subtract_numbers(data1, data2)

end %end switch statement

end %end if-else statement

disp(result);

end %end function do_math_arrays

function array_sum = add_numbers(data1, data2)

array_sum = data1 + data2;

end %end function add_numbers

function array_sub = subtract_numbers(data1, data2)

array_sub = data1 - data2;

end %end function add_numbers

b. A 2-Dimensional array of o's and 1's c. An aray of random intceers d. A single scalar value that is either the number O or the number 1 end tend if-else statenent diun (result); end send function do Ath function an - adc ambsraldatalr data2) 3) If random choice is a 0, what will the values of data1 and data2 be? A 10 x 10, 2-dimensional array of random integers b. a. A1x10, 1-Dimensional array of random integers n sum dataldat:2 c. A 10 x 10, 2-dimensional array containing random numbers between 0 and 100 end send unction add Dumaene function ah-aubtract nunbexa (datal, data2) end %end function add numbers d. A 1 x 10, 2-dimensional array containing 0's and 1's. 4 How many times will the while loop in file 1 repeat? - datal - data2: a. It will never repeat b. It will repeat 1 time c. It wil repeat only if the user types in a 1 at the prompt d. It will repeat if the user types in anything except for the number 0 File 3: 5 What value would the varlable random choce hae to be for the add numbers function from which file 2 to be called? a. 0 b. eault0 svitch user result = add numbers(data1, date2 6) How many output arguments does the function do math arrays return? casc 2 result = _tract numbers(datal, data2) end tend axitch 3tatement c. 2 d. 3 end tend 1i-else atatenent dian (reault) end tend function da maxh axxexs funetion aay add number (atal, data2) end end function add numbers 7) Which functions end up being executed ifte variable random choice is a 0 and a. do math and subtract numberrom file 2), b. do math, subtract numbers(from file 2), and do math arrays c. do math and subtrast numbsus (from file 3) d. do math, do math arravs, and subtract numbers (from file 3) function aa uubtrast nudatal, data2) anau.au.-datal - data2 end send function ad 8) Which functions return something when they are finished executing? They all do None of them do a. b. c. do math arrays, add numbers (file 2), subtract numbers (file 2), add numbers (file 3), and subtract numbers (file 3) subtract numbsrs and add numbsrsin files 2 and 3 1) Which files are functions and which files are scripts? a. All three files are functions d. b. All three files are scripts File 1 is a script, the other two are functions File 2 is a script, the other two are functions d. 2) What is the random choice variable in file 1? a. A 1-Dimensional array of o's and 1's

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!