1. What does MATLAB stand for?
A. Matrix Laboratory
B. Machine Language Tool
C. Memory Algorithm Test Lab
D. Master Analysis Toolkit
Answer: A
2. Which of the following is not a built-in data type in MATLAB?
A. double
B. int
C. float
D. char
Answer: C
3. What does the “clc” command do in MATLAB?
A. Clears the command window
B. Clears the workspace
C. Clears the screen
D. Creates a new window
Answer: A
4. How do you create a row vector in MATLAB?
A. Using the colon operator
B. Using the comma operator
C. Using the semicolon operator
D. Using the period operator
Answer: A
5. What is the output of the following code:
a = [1 2; 3 4];
a(2,1)
A. 1
B. 2
C. 3
D. 4
Answer: C
6. Which of the following is not a valid logical operator in MATLAB?
A. &&
B. ||
C. !
D. &
Answer: D
7. Which of the following functions is used to find the absolute value of a number in MATLAB?
A. abs()
B. ceil()
C. floor()
D. round()
Answer: A
8. What is the output of the following code:
a = [1 2 3];
b = [4 5 6];
c = [a,b];
c(5)
A. 1
B. 2
C. 3
D. 4
Answer: D
9. Which of the following functions is used to generate a random number in MATLAB?
A. rand()
B. round()
C. ceil()
D. floor()
Answer: A
10. What is the output of the following code:
a = [1 2 3];
b = [1; 2; 3];
c = a * b;
A.
1 2 3
2 4 6
3 6 9
B.
14
C.
Error: Inner matrix dimensions must agree.
D.
1 2
2 4
3 6
Answer: C
11. How do you add a new element to the end of a vector in MATLAB?
A. Using the cat() function
B. Using the push() function
C. Using the append() function
D. Using square brackets []
Answer: D
12. How do you create a new line in the command window in MATLAB?
A. Using the enter key
B. Using the tab key
C. Using the shift key
D. Using the control key
Answer: A
13. What is the output of the following code:
a = [1 2 3];
b = [2 4 6];
c = a .* b;
A.
1 2 3
2 4 6
3 6 9
B.
14
C.
6 24 54
D.
2 8 18
Answer: D
14. Which of the following is not a valid conditional statement in MATLAB?
A. if-else
B. switch-case
C. while
D. for
Answer: C
15. How do you find the length of a vector in MATLAB?
A. Using the size() function
B. Using the length() function
C. Using the numel() function
D. Using the dims() function
Answer: B
16. What is the output of the following code:
a = [1 2 3];
b = [1; 2; 3];
c = a + b;
A.
1 2 3
2 4 6
3 6 9
B.
14
C.
2 3 4
3 4 5
4 5 6
D.
Error: Inner matrix dimensions must agree.
Answer: D
17. Which of the following functions is used to find the maximum value of a vector in MATLAB?
A. max()
B. min()
C. mean()
D. sum()
Answer: A
18. How do you access the help documentation for a function in MATLAB?
A. Using the help() function
B. Using the ? operator
C. Using the info() function
D. Using the man() function
Answer: B
19. What is the output of the following code:
a = -5:5;
a(3:8)
A.
-2 -1 0 1 2 3
B.
-2 -1 0 1 2 3 4 5
C.
-5 -4 -3 -2 -1 0
D.
Error: Index exceeds matrix dimensions.
Answer: A
20. How do you clear all variables from the workspace in MATLAB?
A. Using the clear command
B. Using the delete command
C. Using the reset command
D. Using the new command
Answer: A
21. What is the output of the following code:
a = [1 2 3];
b = a’;
c = b(2);
A. 1
B. 2
C. 3
D. Error: Index exceeds matrix dimensions.
Answer: B
22. Which of the following functions can be used to read data from a text file in MATLAB?
A. read()
B. load()
C. import()
D. textread()
Answer: D
23. How do you convert a string to a number in MATLAB?
A. Using the double() function
B. Using the str2num() function
C. Using the num2str() function
D. Using the int() function
Answer: B
24. What is the output of the following code:
a = [1 2 3];
b = [4 5 6];
c = [1 2 3];
d = [a;b;c];
size(d)
A.
3 3
B.
3 9
C.
1 3 3
D.
Error: Dimensions of matrices being concatenated are not consistent.
Answer: B
25. What is the output of the following code:
a = [1 2 3; 4 5 6];
b = [1; 2];
c = a * b;
A.
3 5
B.
7 16
C.
Error: Inner matrix dimensions must agree.
D.
1 2
4 8
Answer: C
26. Which of the following functions is used to find the roots of a polynomial in MATLAB?
A. roots()
B. polyval()
C. polyfit()
D. polyder()
Answer: A
27. How do you access the nth element of a vector in MATLAB?
A. Using the n() function
B. Using the nth() function
C. Using square brackets []
D. Using the index operator ()
Answer: D
28. What is the output of the following code:
a = [1 2 3];
b = [2 4 6];
c = norm(a-b);
A. 0
B. 1.7321
C. 3
D. Error: Dimensions must agree.
Answer: B
29. Which of the following is not a valid way to define a matrix in MATLAB?
A. Using square brackets []
B. Using the reshape() function
C. Using the ones() function
D. Using the zeros() function
Answer: B
30. What is the output of the following code:
a = [1 2 3];
b = [4 5 6];
c = [1 2 3];
d = [a’;b’;c’];
size(d)
A.
3 3
B.
3 9
C.
1 3 3
D.
3 1 3
Answer: D
31. How do you insert a value into a specific location in a vector or matrix in MATLAB?
A. Using the insert() function
B. Using the overwrite() function
C. Using the replace() function
D. Using the index operator ()
Answer: D
32. What is the output of the following code:
a = [1 2 3];
b = [2 4 6];
c = a * b’;
A.
2 4 6
4 8 12
6 12 18
B.
14
C.
7 14 21
D.
Error: Inner matrix dimensions must agree.
Answer: C
33. Which of the following functions is used to sort a vector in ascending order in MATLAB?
A. sort()
B. reverse()
C. flip()
D. flipud()
Answer: A
34. How do you create a diagonal matrix in MATLAB?
A. Using the diag() function
B. Using the diagmat() function
C. Using the diagvec() function
D. Using the diagmatrix() function
Answer: A
35. What is the output of the following code:
a = [1 2 3; 4 5 6];
b = [1; 2];
c = [a,b];
d = [b’,a’];
A.
1 2 3 1
4 5 6 2
B.
1 4 2 5 3 6
1 2
C.
1 4
2 5
3 6
1 2
D.
Error: Dimensions of matrices being concatenated are not consistent.
Answer: D
36. Which of the following functions is used to find the eigenvalues of a matrix in MATLAB?
A. eig()
B. trace()
C. det()
D. rank()
Answer: A
37. How do you access the imaginary part of a complex number in MATLAB?
A. Using the real() function
B. Using the imag() function
C. Using the complex() function
D. Using the conj() function
Answer: B
38. What is the output of the following code:
a = [1 2 3];
b = 2;
c = a .* b;
A.
1 2 3
2 4 6
3 6 9
B.
2 4 6
C.
2 2 2
D.
Error: Inner matrix dimensions must agree.
Answer: C
39. Which of the following is not a valid way to create a cell array in MATLAB?
A. Using curly braces {}
B. Using the cell() function
C. Using the mat2cell() function
D. Using the struct() function
Answer: D
40. What is the output of the following code:
a = [1 2 3];
b = [2 4 6];
c = a + b’;
A.
3 6 9
B.
1 3
3 6
5 9
C.
Error: Inner matrix dimensions must agree.
D.
3 6
Answer: B
41. How do you loop through the elements of a vector in MATLAB?
A. Using the for loop
B. Using the while loop
C. Using the do-while loop
D. Using the case loop
Answer: A
42. What is the output of the following code:
a = [1 2 3];
b = [2 4 6];
c = a * b;
A.
3 5
B.
7 16
C.
Error: Inner matrix dimensions must agree.
D.
1 2
4 8
Answer: C
43. Which of the following functions is used to find the index of the maximum value in a vector in MATLAB?
A. max()
B. min()
C. find()
D. sort()
Answer: C
44. How do you access the help documentation for a specific command in MATLAB?
A. Using the help() function followed by the command name
B. Using the ? operator followed by the command name
C. Using the doc() function followed by the command name
D. Using the man() function followed by the command name
Answer: B
45. What is the output of the following code:
a = [1 2 3];
b = [2 4 6];
c = [1 2 3];
d = [a’,b’,c’];
size(d)
A.
3 3
B.
3 9
C.
1 3 3
D.
3 1 3
Answer: B
46. Which of the following functions is used to find the median value of a vector in MATLAB?
A. median()
B. mean()
C. std()
D. var()
Answer: A
47. How do you access the real part of a complex number in MATLAB?
A. Using the real() function
B. Using the imag() function
C. Using the complex() function
D. Using the conj() function
Answer: A
48. What is the output of the following code:
a = [1 2 3; 4 5 6];
b = [1; 2];
c = [a;b];
d = [b’;a’];
A.
1 2 3 1
4 5 6 2
B.
1 4 2 5 3 6
1 2
C.
1 4
2 5
3 6
1 2
D.
Error: Dimensions of matrices being concatenated are not consistent.
Answer: D
49. What is the output of the following code:
a = [1 2 3];
b = [2 4 6];
c = [3 6 9];
d = [a’;b’;c’];
size(d)
A.
3 3
B.
3 9
C.
1 3 3
D.
3 1 3
Answer: B
50. Which of the following functions is used to find the standard deviation of a vector in MATLAB?
A. std()
B. mean()
C. median()
D. var()
Answer: A
- Top 10 DevOps Trainers in the world - October 7, 2023
- What is Cookies and Why it is Used? - May 24, 2023
- TOP trends of transitions in TikTok - May 10, 2023