1 2 Basics Input Output On Matlab Quiz
1 2 Basics Input Output On Matlab Quiz
A = [0 1; 1 0] ; B=2 ; C=A+B
a)
1 2
4 5
b)
2 3
3 2
c)
3 2
3 2
d)
3 2
2 3
Answer b
2. What would be the output of the following code (in editor window)?
A = [1 0 2] ; b = [3 0 7] ; c=a.*b;
a) [2 0 21]
b) [3 0 14]
c) [14 0 3]
d) [7 0 3]
Answer b
3. What would be the output of the following code (in editor window)?
a=1:5 ; c=a.^2
a) [1 25]
b) [1 2 3 4 5]
c) [25 16 9 4 1]
d) [1 4 9 16 25]
Answer d
4. What would be the output of the following code (in editor window)?
A = [1 1 0 0]
B = [1 ;2 ;3 ;4]
C=A*B
a) 0
b) [1 0 0 0]
c) 3
d) [1 2 0 0]
Answer c
5. What would be the output of the following code (in editor window)?
A = [1 2; 3 4]
C = A^2
a) [7 10; 15 22]
b) [1 4; 9 16]
c) [16 9; 4 1]
d) [22 15; 10 7]
Answer a
6. What would be the output of the following code (in editor window)?
A=1:5;
B=cumprod(A)
a) b=[1 2 6 24 120]
b) b=[1 2 3 4 5]
c) b=[5 4 3 2 1]
d) b=[120 24 6 2 1]
Answer a
7. Create an array of logical values.
0 1 0
b)
B=1 0 0
1 1 0
c)
B=1 0 0
1 1 1
d)
B=1 1 0
1 1 0
Answer b
8. Find the cumulative sum of the columns of A.
A =1 4 7
2 5 8
3 6 9
B = cumsum(A)
a)
B=1 4 7
3 8 15
6 15 24
b)
B=1 4 7
4 9 15
4 15 24
c)
B=1 4 7
3 9 15
6 15 29
d)
B=1 4 7
3 9 15
6 15 24
Answer d
9. Create a 4-by-2-by-3 array of ones and compute the sum along the third dimension.
A = ones(4,2,3);
S = sum(A,3)
a)
S=3 3
3 3
3 3
3 3
b)
S=3 4
3 4
3 4
3 4
c)
S=2 3
2 3
2 3
2 3
d)
S=7 3
5 3
6 3
3 3
Answer a
1. Round each value in a duration array to the nearest number of seconds greater than or equal to
that value.
b)
c)
d)
Answer a
2. What would be the output of the following code (in editor window)?
3. Compute 24 modulo 5.
b = mod(24,5)
a) b = 3
b) b =4
c) b =5
d) b =6
Answer b
4. What would be the output of the following code (in editor window)?
R=1 2 1
4 0 9
1 0 0
b)
R=1 2 3
3 0 2
1 0 0
c)
R=1 2 3
4 1 2
1 1 0
d)
R=1 2 3
4 0 2
1 0 0
Answer d
5. If one operand is a scalar and the other is not, then MATLAB applies the scalar to every
element of the other operand. This property is known as ______________
a) operand divergence
b) scalar expansion
c) vector expansion
d) dimension declaration
Answer b
6. Matrix operations follow the rules of linear algebra and are not compatible with
multidimensional arrays.
a) true
b) false
Answer a
7. Conversion Function int16 uses_________ range of value?
a) -27 to 27-1
b) -215 to 215-1
c) -231 to 231-1
d) 0 to 216-1
Answer b
8. Largest and smallest values for integer classes is 127 to -128.
a) True
b) False
Answer a
y= 3x5 + x2 + 6
a) y=[3,0,0,1,0,6]
b) y=[3,1,6]
c) y=[3;0;0;1;0;6]
d) y=[6,0,1,0,0,3]
Answer a
3. In the function vpa(‘981’,10), why do we put 981 within inverted commas?
a) We can choose to not put the value within a pair of single inverted comma
b) We do it so that we don’t get an approximated value
c) We do it to get the exact value as MATLAB computes exact values, of numerical expressions,
when declared within a string
d) We do it to get a floating-point approximated value, approximated to 14 digits
Answer c
4. How would you simplify log(x20) – log(x13) – log(x7) in MATLAB? (Assume x is defined as a
string variable)
a) simplify(log(x20)-log(x13)–log(x7));
b) log(x20) – log(x13) – log(x7)
c) simplify(log(x20)-log(x13)–log(x7),’IgnoreAnalyticConstraints’,true)
d) simplify(log(x20)-log(x13)–log(x7))
Answer c
5. What happens if we don’t assign a variable to an expression which evaluates a numerical
value?
a) MATLAB shows error
b) Nothing happens
c) The evaluated values are assigned to a variable ans automatically
d) Depends on the numerical value
Answer c
6. MATLAB sees a ________ ordered variable as a vector of dimension n*1.
a) nth, (n+2)th
b) nth, (n+3)th
c) (n-1)th, nth
d) nth, (n-1)th
Answer c
7. What will be the output for the below block of code?
r = -2
-1
Answer d
8. Name the functions used, for multiplication and division of two polynomials in MATLAB.
a) conv() and deconv()
b) mult() and div()
c) conv() and div()
d) mult and div
Answer a
9. How can the formulation of polynomial be done from its roots?
a) poly(r), r is a row vector, containing the roots of the polynomial
b) poly([roots as a coloumn vector])
c) poly([roots as a row vector])
d) poly([roots in descending order as a coloumn vector])
Answer b
10. The function to evaluate the value of a polynomial,l for a constant value of the independent
variable(say a) in the polynomial is ______
a) poly(p,a), p is a row vector
b) polyder(p)
c) polyint(p)
d) polyval(c,a), c is a row vector
Answer d