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

PS11.3 Without actually using MATLAB answer the following questions. You just ne

ID: 2265854 • Letter: P

Question

PS11.3 Without actually using MATLAB answer the following questions. You just need to circle the correct letter. Ambiguous responses receive zero credit. Let >>represent the command prompt a. What is the displayed result of executing the following script?: >> X= [2:4; -1:1; 1 2 3]; Y-X(2, :) ; size (Y') A: >> 2 2 B: 3 1 C>2 1 D: 13E: None of the others b. What is the value for y after the while loop ends in the following script file in MATLAB? x =0 :10; -false; y i =1; while x(1)

Explanation / Answer

Matlab Script:

X= [2:4;-1:1;1 2 3];
Y = X(2,:);%return second row which is of dimension 1 by 3
size(Y') %returns size or dimension of transpose of Y which is 3 by 1 answer is B

x = 0:10;
y = false;
i=1;
%below loop runs for 10 times and for every even number of iterations y will be false and for every odd number of iterations y is true
while x(i)<10
i=i+1;
y = ~y;
end
%option D is correct

x = zeros(10,1);
for j=1:5
x(2*j) = 1;%inserting 1's in even indices
end
y = zeros(10,1);
for j=0:4
y(2*j+1)=1;%inserting 0's in odd indices
end

z = x+y;%contains all 1's option B
w = x.*y;%element by element multiplication which will be all zeros option B
v = y'*x;%normal matrix multiplication which gives 0 a scalar