EE 350 Fall 2017 NON-TEXT HW PROBLEMS PS11.3 CONTUNUED... d. Given the following
ID: 2265784 • Letter: E
Question
EE 350 Fall 2017 NON-TEXT HW PROBLEMS PS11.3 CONTUNUED... d. Given the following script function [y,z] = Fina!Exam (x) y =1 ; if x--y Y-100; else z-100; end end d.1 If w-FinalExam (100)100, what is w? A. w-true | B: w=10 | C: w-100 | D: w=false | E: None of the others d.2 If [u, v]-FinalExam (0), which of the following is true? A: v>=u; | B: v0 | E: None of the others e. Given the Vector Z= [ 10 2 34 5 6 7 ] , which of the answers below will yield 34? A: Z[1]; B: 2 [2] C: Z[3] D: Z[4] E: None of the others f. Given the following script, what value will x be, when the loop finishes?: for n=1 : 10 x-n-1; end A: 1 B: 4; C: 9; D: 10E: None of the others g. Given the following script, if x--5 what does y equal? if (x 1) y=x ; y-24; y=x* 2 ; else if (x>1) else end A: 1 B: 10; C:-10;D: 12 E: None of the othersExplanation / Answer
Matlab Script:
%part d
w = FinalExam(100)==100;%FinalExam(100) returns y value 1 hence condition is false
[u,v] = FinalExam(0);%we get u=y=1 and v=z=100 v>=u option a is correct
%part e
z = [10 2 34 56 7];
%34 is at index 3 z[3] will return 34
%part f
for n=1:10
x = n-1;
end
%In every loop x is changing final value of n is 10 when n=10 x will be 9
%part g
x=-5;
if (x==1)
y=x;
else if (x>1)
y = 24;
else %x value satisfies here so y will be -10
y=x*2
end
FinalExam.m script:
function [y,z] = FinalExam(x)
y=1;
z=0;
if x==y
y=100;
else
z=100;
end
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.