Skip to content
- What is the default data type for a variable in MATLAB?
- A) Integer
- B) String
- C) Double
- D) Char
- Which command is used to clear all variables from the workspace?
- A) clear all
- B) clearvars
- C) remove all
- D) deletevars
- How do you create a 3×3 identity matrix in MATLAB?
- A) eye(3)
- B) id(3)
- C) matrix(3)
- D) ones(3)
- Which function is used to find the size of a matrix?
- A) length()
- B) size()
- C) dimensions()
- D) matrix_size()
- What operator is used for matrix multiplication?
- How would you create a row vector with values from 1 to 10?
- A) [1:10]
- B) (1:10)
- C) {1:10}
- D) [1; 10]
- What is the command for generating random numbers in a specified range?
- A) rand(min, max)
- B) random(min, max)
- C) randi(min, max)
- D) randrange(min, max)
- Which command displays a message in the command window?
- A) show()
- B) display()
- C) fprintf()
- D) msg()
- What is the primary file extension for MATLAB scripts?
- A) .mat
- B) .ml
- C) .m
- D) .txt
- Which function is used to plot a graph in MATLAB?
- A) plot()
- B) graph()
- C) chart()
- D) draw()
- In MATLAB, how do you access the third element of a vector named
vec?
- A) vec[3]
- B) vec(3)
- C) vec{3}
- D) vec.3
- What is the command to save the current workspace variables to a file?
- A) savefile()
- B) save()
- C) export()
- D) store()
- Which function is used to read data from a text file?
- A) readfile()
- B) load()
- C) importdata()
- D) readdata()
- How do you comment a single line in MATLAB?
- What function generates normally distributed random numbers?
- A) randn()
- B) randomn()
- C) normrand()
- D) gaussian()
- Which command is used to find the maximum value in an array?
- A) maxvalue()
- B) maximum()
- C) max()
- D) highest()
- How can you concatenate two matrices
A and B vertically?
- A) A || B
- B) A + B
- C) [A; B]
- D) [A B]
- What is the MATLAB function for the exponential of a matrix?
- A) exp()
- B) exponent()
- C) power()
- D) expm()
- What would the command
linspace(1, 10, 5) generate?
- A) 5 random numbers
- B) 5 evenly spaced numbers from 1 to 10
- C) 5 integers from 1 to 10
- D) 10 numbers from 1 to 5
- How can you delete the first row of a matrix
M?
- A) M(1,:) = []
- B) M(1) = []
- C) delete(M(1,:))
- D) remove(M(1,:))
- Which command is used to add a title to a plot?
- A) title()
- B) xlabel()
- C) legend()
- D) annotation()
- In MATLAB, which command is used to calculate the mean of an array?
- A) average()
- B) mean()
- C) midpoint()
- D) findmean()
- What does the command
clc do in MATLAB?
- A) Clears the command window
- B) Clears variables
- C) Closes figures
- D) Clears the plot
- How can you execute a script file named
script.m?
- A) run script.m
- B) execute script.m
- C) script
- D) run <script.m>
- Which operator is used for element-wise multiplication?
- A) *
- B) .
- C) .*
- D) element*
- In MATLAB, how is a string created?
- A) “string”
- B) ‘string’
- C)
string
- D) {string}
- What would
A = [1 2; 3 4]; B = A'; do?
- A) Create matrix B as a transpose of A
- B) Add A and B
- C) Multiply A by B
- D) Create an identity matrix
- Which command is used to plot a bar graph?
- A) barplot()
- B) bar()
- C) histogram()
- D) plotbar()
- How do you create a 3D plot in MATLAB?
- A) plot3()
- B) 3Dplot()
- C) graph3()
- D) plot3d()
- What command is used to find the determinant of a matrix?
- A) det()
- B) determinant()
- C) matrixDet()
- D) finddet()
- What does the command
pause do in MATLAB?
- A) Stops execution
- B) Delays execution for a specified amount of time
- C) Restarts execution
- D) Continues execution
- How do you access the elements of a matrix M at row 2, column 1?
- A) M(2, 1)
- B) M[2][1]
- C) M.2.1
- D) M(1, 2)
- Which function in MATLAB is used to plot a histogram?
- A) hist()
- B) histogram()
- C) hplot()
- D) bar()
- What command would you use to add a grid to a plot?
- A) grid()
- B) addgrid()
- C) gridon()
- D) showgrid()
- How can you create a logical array in MATLAB?
- A) [true, false]
- B) (true, false)
- C) {true, false}
- D) <true, false>
- Which function is used to create a scatter plot?
- A) scatterplot()
- B) scatter()
- C) plotscatter()
- D) graphscatter()
- What does the command
disp() do?
- A) Displays a variable or message in the command window
- B) Deletes a variable
- C) Displays current variables
- D) Discards a variable
- How can you convert a number to a string in MATLAB?
- A) num2str()
- B) str2num()
- C) numberToString()
- D) convertNum()
- Which command is used to check if a variable exists?
- A) exists()
- B) isvar()
- C) ismember()
- D) exist()
- How do you initialize a variable as an array with 10 zeros?
- A) zeros(10)
- B) array(10, 0)
- C) [0,0,0,0,0,0,0,0,0,0]
- D) zeros[10]
- What does the command
axis equal do?
- A) Sets the axis limits
- B) Makes the scale of the axes equal
- C) Equalizes the data points
- D) Sets the axes to zero
- What is the scope of a variable defined inside a function?
- A) Global
- B) Local
- C) Static
- D) Default
- Which function would you use to calculate square roots in MATLAB?
- A) sqrt()
- B) root()
- C) squareroot()
- D) power(0.5)
- How do you append a value to a vector named
vec?
- A) vec = [vec, newValue]
- B) append(vec, newValue)
- C) add(vec, newValue)
- D) vec.add(newValue)
- What is the purpose of the
for loop in MATLAB?
- A) To repeat code a specific number of times
- B) To create functions
- C) To control if-else statements
- D) To perform data analysis
- What is the command to close all figure windows?
- A) close all
- B) close all()
- C) figure close()
- D) clearfigures()
- How do you plot sine wave values using the
sin() function?
- A) plot(sin(x))
- B) sin(x)
- C) plot(y)
- D) sine(y)
- Which operator is used for scalar division?
- What does
isempty() function check in MATLAB?
- A) If a variable is empty
- B) If an array has no elements
- C) Both A and B
- D) If a matrix is singular
- What command would you use to sort an array in ascending order?
- A) sortasc()
- B) sort()
- C) ascending()
- D) order()