Week - 2 Question Sheet
Week - 2 Question Sheet
y = a + b , a = 2 ; b = sqrt(‐4) ;
returns
a. 2 + 2 i
b. 2 ‐ 2 i
c. error message
d. NaN
Q2. Write the MATLAB command to generate a vector z that starts from 0, ends at 2000,and
count by 3?
Q4. Write the matlab commands to generate a vector w that starts at 1 and counts by squares
to 576(24^2),that is: 1 4 9 16..
d. (x.^2)/y(end-2)
Q7. After the code below executes, what does the variable x1 contain?
aa = linspace(0,pi,10);
x1 = cos(aa(10));
a. -1
b. 0
c. +1
d. error - not possible
e. some number that is not -1, 0, or +1
Q10. What value does the variable q contain after the Matlab code below executes?
a = [ 1 3 5 ];
q = a.*a;
q = q + 2;
a. [3 11 27]
b. nothing - operation is not possible
c. [1 3 5]
d. [3 5 7]
Q11.When used in the fprintf command, the \n is used to
a) add a space between any two characters
b) add a line space (enter key)
Q12.To display 'Question 2' in the command window, the correct command is
a) disp(Question 2)
b) display('Question 2')
c) disp('Question 2')
d) Question 2
a = 1:2 ; size(a)
returns
a. error message
b. 1 2
c. 2 1
d. 2
e. none of above
Q21. Which MATLAB statement is correct for obtaining a vector where the elements are
formed using
Q22. What is the value of D after the following MATLAB commands are executed:
A = [ 1 2 ; 3 4 ];
B = [ 0 1 ; 2 1 ];
C = A .* B;
D = B * C;
Q23. Consider the following MATLAB script:
z = [ 2 -1 ];
x = z(1);
y = z(2);
w1 = x^2 + y^2;
w2 = x;
output = [ w1 ; w2 ]
what is the value of output?
Q24. If the coefficient matrix of a linear system is non-singular, this means that there is exactly
one
solution to the problem (i.e., there is a unique solution to the linear system).
A. True
B. False
Q25. Give the MATLAB commands to create a 7x7 matrix with twos in the first and fourth rows
and zeroes elsewhere.
A. A([1,end], [1,end])
B. A([1,1], [end,end])
C. A({[1,1], [1,end], [end,1], [end,end]})
D. A(1:end, 1:end)