Top 47 MATLAB MCQs With Answers
Top 47 MATLAB MCQs With Answers
A) new
B) var
C) create
D) let
Answer: B) var.
A) .mat
B) .m
C) .md
D) .txt
Answer: B) .m.
A) while
B) do-while
C) for
D) repeat-until
Answer: C) for.
A) show
B) display
C) disp
D) print
Answer: C) disp.
A) 16
B) 13
C) 11
D) 15
Answer: D) 13.
Explanation: The expression is evaluated using the order of operations, so the
multiplication is done first, followed by the addition. Thus, the result is 3 + 10 = 15.
7. Which of the following commands is used to create a matrix with all elements
set to 0?
A) zeros
B) ones
C) eye
D) rand
Answer: A) zeros.
A) sqrt
B) root
C) power
D) exp
Answer: A) sqrt.
A) random
B) rand
C) randn
D) randomize
Answer: B) ranD)
10. Which of the following commands is used to read input from the user in
MATLAB?
A) input
B) read
C) readln
D) get
Answer: A) input.
a = [1 2 3; 4 5 6];
b = [7 8 9; 10 11 12];
c = a + b;
A) [8 10 12; 14 16 18]
B) [7 8 9 10 11 12]
C) [7 10 12; 14 16 18]
D) [8 11 14; 17 20 23]
Explanation: The code creates two matrices, ‘a’ and ‘b’, and then adds them together
using the ‘+’ operator. The resulting matrix ‘c’ is:
A) plot
B) createplot
C) drawplot
D) makeplot
Answer: A) plot.
13. Which of the following commands is used to find the maximum element of a
matrix in MATLAB?
A) min
B) max
C) maximum
D) findmax
Answer: B) max.
A) horzcat
B) vertcat
C) cat
D) merge
Answer: B) vertcat.
15. Which of the following commands is used to calculate the dot product of two
vectors in MATLAB?
A) dot
B) cross
C) inner
D) product
Answer: A) dot.
x = 1:5;
y = x.^2;
A) x = [1 2 3 4 5], y = [1 4 9 16 25]
B) x = [1 2 3 4 5], y = [2 4 6 8 10]
C) x = [1 2 3 4 5], y = [1 2 3 4 5]
D) x = [1 2 3 4 5], y = [1 3 5 7 9]
Explanation: The code creates a vector ‘x’ with values 1 through 5, and then creates a
new vector ‘y’ by squaring each element of ‘x’. The resulting vector ‘y’ is [1 4 9 16 25].
Answer: A) upper.
18. Which of the following commands is used to round a number to the nearest
integer in MATLAB?
A) round
B) ceil
C) floor
D) fix
Answer: A) rounD)
19. Which of the following commands is used to find the indices of the non-zero
elements in a matrix in MATLAB?
A) nonzero
B) find
C) index
D) locate
Answer: B) finD)
Explanation: The code creates a vector ‘x’ with values ranging from 0 to 2*pi in
increments of pi/10, and then creates a new vector ‘y’ by taking the sine of each
element of ‘x’. The resulting vectors ‘x’ and ‘y’ both have 21 elements.
A) random
B) rand
C) randomize
D) randn
Answer: B) ranD)
22. Which of the following commands is used to calculate the inverse of a matrix
in MATLAB?
A) inverse
B) inv
C) transpose
D) invert
Answer: B) inv.
23. Which of the following commands is used to calculate the square root of a
number in MATLAB?
A) sqrt
B) square
C) squareroot
D) root
Answer: A) sqrt.
A) transpose
B) trans
C) t
D) tr
Answer: C) t.
x = [1 2; 3 4];
y = [5 6; 7 8];
z = x*y;
A) z = [7 10; 15 22]
B) z = [19 22; 43 50]
C) z = [11 14; 23 26]
D) z = [12 15; 18 21]
Explanation: The code creates two 2×2 matrices ‘x’ and ‘y’, and then multiplies them
using the * operator to create a new matrix ‘z’. The resulting matrix ‘z’ is [19 22; 43 50].
A) det
B) determinant
C) detmat
D) matdet
Answer: A) det.
27. Which of the following commands is used to calculate the mean of a matrix in
MATLAB?
A) mean
B) avg
C) average
D) matmean
Answer: A) mean.
28. Which of the following commands is used to calculate the standard deviation
of a matrix in MATLAB?
A) stddev
B) stdev
C) std
D) deviation
Answer: C) stD)
A) diag
B) diagonal
C) diags
D) matdiag
Answer: A) diag.
x = [1 2 3];
y = [4 5 6];
z = [7 8 9];
a = [x; y; z];
A) a = [1 2 3; 4 5 6; 7 8 9]
B) a = [1 4 7; 2 5 8; 3 6 9]
C) a = [1 2 3 4 5 6 7 8 9]
D) a = [1 2 3; 4 5 6; 7 8 9;]
Answer: B) a = [1 4 7; 2 5 8; 3 6 9].
Explanation: The code creates three 1×3 row vectors ‘x’, ‘y’, and ‘z’, and then
combines them into a 3×3 matrix ‘a’ using the semicolon (;) operator. The resulting
matrix ‘a’ is [1 4 7; 2 5 8; 3 6 9].
31. Which of the following commands is used to find the maximum value in a
matrix in MATLAB?
A) maxval
B) max
C) maximum
D) matmax
Answer: B) max.
32. Which of the following commands is used to find the minimum value in a
matrix in MATLAB?
A) minval
B) min
C) minimum
D) matmin
Answer: B) min.
33. Which of the following commands is used to calculate the dot product of two
vectors in MATLAB?
A) dot
B) product
C) dotprod
D) vecdot
Answer: A) dot.
34. Which of the following commands is used to calculate the cross product of
two vectors in MATLAB?
A) crossprod
B) cross
C) veccross
D) xprod
Answer: B) cross.
35. Which of the following commands is used to calculate the norm of a vector in
MATLAB?
A) norm
B) vecnorm
C) vectornorm
D) normvec
Answer: A) norm.
36. Which of the following commands is used to calculate the eigenvalues of a
matrix in MATLAB?
A) eig
B) eigen
C) eigm
D) mat_eig
Answer: A) eig.
A) spr
B) sparse
C) sparsify
D) sp_matrix
Answer: B) sparse.
A) size
B) reshape
C) resize
D) arrayresize
Answer: B) reshape.
39. Which of the following commands is used to concatenate two matrices
horizontally in MATLAB?
A) horzcat
B) cat
C) concat
D) hcat
Answer: A) horzcat.
A) vertcat
B) cat
C) concat
D) vcat
Answer: A) vertcat.
A) rand
B) randn
C) randi
D) random
Answer: A) ranD)
42. Which of the following commands is used to generate a random integer
between two specified values in MATLAB?
A) rand
B) randn
C) randi
D) random
Answer: C) randi.
A) rand
B) randn
C) randi
D) random
Answer: B) randn.
A) ceil
B) floor
C) round
D) int
Answer: A) ceil.
45. Which of the following commands is used to round a number down to the
nearest integer in MATLAB?
A) ceil
B) floor
C) round
D) int
Answer: B) floor.
A) plot
B) createplot
C) plotgraph
D) drawplot
Answer: A) plot.
47. Which of the following commands is used to create a scatter plot in MATLAB?
A) plot
B) scatter
C) scatterplot
D) plotscatter
Answer: B) scatter.