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

~~~~~~~~~Posted below is a problem in MATLAB, please answer and provide the corr

ID: 3863718 • Letter: #

Question

~~~~~~~~~Posted below is a problem in MATLAB, please answer and provide the correct coding and functions. Thanks!~~~~~~~~~~~~~~

1. i. Write a function called myfunction that takes two input numbers a and b and output two values C1 and O2. oi is calculated as the first input divided by the second input. O2 is the sum of the two inputs. The function checks to make sure the inputs are all scalars, else it prints an error message. ii. On MATLAB's command prompt, how will you call your function with a 12 and b 34 while assigning your function's returns to the variable joe and mary. 2 a. Given the following matrix, A 13 7 9 4 5], show the results generated by MATLAB command, fprintf(x F .5fn', A) b. Given pl 5, p2 11, p3-12.542 p4 33.45 Write an fprintf statement(s) that will output the following statement: The cost to ship 5 pounds, 11 ounces using Ground Transportation is USD 22.15 BUT The cost to ship 12.542 pounds using Express is $33.45

Explanation / Answer

%matlab code


%part 1.1
function [O1 O2] = myfunction(a,b)
O1 = a/b;
O2 = a+b;
end

%part 1.2
[joe mary] = myfunction(12,34);
%output: joe=0.3529 mary=46


%part 2.1
A= [3 7 9 4 5];
fprintf('x=%5f ',A);
%{
   output:
   x=3.000000
   x=7.000000
   x=9.000000
   x=4.000000
   x=5.000000
}

%part 2.2
p1=5;
p2=11;
p3=12.542;
p4=33.45;
fprintf('The cost to ship %d pounds, %d ounces using Ground Transportation is USD 22.15 BUT The cost to ship %0.3f pounds using Express is $%0.2f',p1,p2,p3,p4);