MATLAB MCQs

1. What is the default data type for variables in MATLAB?
A) Integer
B) Float
C) Double
D) String

Answer: C) Double

2. How do you create a 3×3 matrix of zeros in MATLAB?
A) zeros(3,3)
B) zeros(3)
C) zeros(3,3,3)
D) matrix(3,3)

Answer: A) zeros(3,3)

3. What does the size function do in MATLAB?
A) Returns the size of a variable
B) Resizes a variable
C) Returns the shape of a matrix
D) Deletes the variable

Answer: A) Returns the size of a variable

4. How do you create a vector with values from 1 to 10 in MATLAB?
A) 1:10
B) linspace(1,10,10)
C) range(1,10)
D) vector(1,10)

Answer: A) 1:10

5. How do you comment a single line in MATLAB?
A) // comment
B) # comment
C) % comment
D) /* comment */

Answer: C) % comment

6. What is the output of length([1,2,3;4,5,6])?
A) 3
B) 6
C) 2
D) 9

Answer: C) 2

7. How do you transpose a matrix A in MATLAB?
A) A’
B) transpose(A)
C) A.T
D) A.

Answer: A) A’

8. Which function is used to plot a graph in MATLAB?
A) plot()
B) graph()
C) draw()
D) show()

Answer: A) plot()

9. How do you find the determinant of a matrix A?
A) det(A)
B) matrixdet(A)
C) finddet(A)
D) A.det()

Answer: A) det(A)

10. What is the purpose of the clear command in MATLAB?
A) Clears all variables from the workspace
B) Clears the command window
C) Clears the figure window
D) Clears the current function

Answer: A) Clears all variables from the workspace

11. How do you create a new figure window in MATLAB?
A) figure()
B) plot()
C) newfig()
D) window()

Answer: A) figure()

12. What is the output of sum([1,2,3;4,5,6])?
A) 21
B) [10, 15]
C) [6, 15]
D) [10, 11, 12]

Answer: A) 21

13. How do you perform element-wise multiplication in MATLAB?
A) .*
B) *
C) .
D) ×

Answer: A) .*

14. What is the purpose of the linspace function in MATLAB?
A) Creates a vector with linearly spaced values
B) Creates a matrix with linearly spaced values
C) Creates a vector with random values
D) Creates a matrix with random values

Answer: A) Creates a vector with linearly spaced values

15. How do you concatenate two matrices A and B horizontally?
A) [A B]
B) concat(A, B)
C) A+B
D) hcat(A, B)

Answer: A) [A B]

16. Which function is used to calculate the mean of an array in MATLAB?
A) mean()
B) average()
C) median()
D) sum()

Answer: A) mean()

17. How do you create a 4×4 identity matrix in MATLAB?
A) eye(4)
B) identity(4)
C) ones(4)
D) diag(4)

Answer: A) eye(4)

18. What does the reshape function do in MATLAB?
A) Changes the dimensions of a matrix
B) Sorts the elements of a matrix
C) Reverses the elements of a matrix
D) Finds the maximum element of a matrix

Answer: A) Changes the dimensions of a matrix

19. How do you find the maximum value in a vector v?
A) max(v)
B) maximum(v)
C) findmax(v)
D) v.max()

Answer: A) max(v)

20. What is the default plot line color in MATLAB?
A) Blue
B) Red
C) Green
D) Black

Answer: A) Blue

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>