MATLAB Certification Exam — Questions and Answers
Question 1: How do you delete the third row of matrix A in MATLAB?
- A(3) = []
- remove(A, 3)
- A(3, :) = [] (Correct answer)
- delete(A, 3, 'row')
Correct answer: A(3, :) = []
Assigning `[]` to a full row slice `A(3, :)` removes that row from the matrix.
Question 2: In MATLAB's `fft(x, N)`, what does the parameter N specify?
- The highest frequency bin to compute
- The normalization factor applied to the output
- The number of FFT points (DFT length), zero-padding x if N > length(x) (Correct answer)
- The number of overlapping segments
Correct answer: The number of FFT points (DFT length), zero-padding x if N > length(x)
N sets the DFT length; if N exceeds the signal length, MATLAB zero-pads x to N samples, providing interpolated frequency resolution.
Question 3: An engineer has an Excel file, 'test_results.xlsx', with data on multiple worksheets named 'Trial1', 'Trial2', and 'Trial3'. What is the first step required to programmatically import the data from 'Trial2' into a table?
- Use `xlsread('test_results.xlsx', 'Trial2')` as it's the only way.
- Open the file in Excel and save 'Trial2' as a separate CSV file.
- First, use `sheetnames('test_results.xlsx')` to get all sheet names, then loop through them.
- Use `readtable('test_results.xlsx', 'Sheet', 'Trial2')`. (Correct answer)
Correct answer: Use `readtable('test_results.xlsx', 'Sheet', 'Trial2')`.
The `readtable` function can directly access specific worksheets within an Excel file by using the 'Sheet' name-value pair argument. This allows for direct and efficient importing without needing to open Excel or pre-process the file. While getting all sheet names first is a valid strategy for importing all sheets, it's not the necessary first step for importing just one specific sheet. `xlsread` is no longer the recommended function.
Question 4: What is the result of logical short-circuit evaluation using '&&' vs '&' in MATLAB?
- '&&' short-circuits scalar operands and skips evaluating the right side if the left is false; '&' always evaluates both sides element-wise (Correct answer)
- '&' short-circuits; '&&' does not
- They are identical for all inputs
- '&&' is for arrays; '&' is for scalars
Correct answer: '&&' short-circuits scalar operands and skips evaluating the right side if the left is false; '&' always evaluates both sides element-wise
'&&' performs short-circuit AND on scalars, skipping the right operand when the left is false; '&' always evaluates both operands element-wise.
Question 5: Which statement correctly defines a function handle in MATLAB?
- f = def(x) x^2 end
- f = function(x) x^2
- f = @(x) x^2 (Correct answer)
- f = lambda x: x^2
Correct answer: f = @(x) x^2
The '@(x) x^2' syntax creates an anonymous function handle in MATLAB.
Question 6: Which MATLAB command is used to clear all variables from the workspace?
- clc
- clear (Correct answer)
- delete all
- reset
Correct answer: clear
The clear command removes all variables from the current workspace; clc only clears the Command Window text.
Question 7: How do you remove a field `z` from struct `s` in MATLAB?
- s = removefield(s, 'z')
- delete(s.z)
- rmfield(s, 'z') (Correct answer)
- s.z = []
Correct answer: rmfield(s, 'z')
`rmfield(s, 'z')` returns a new struct without the field `z`; it does not modify `s` in place.
Question 8: What do MATLAB MEX files do?
- No such thing as MEX files
- Helps to analyze commands in MATLAB
- Allows the user to combine C source files with Matlab files (Correct answer)
- Same as MAT files
Correct answer: Allows the user to combine C source files with Matlab files
MEX files (MATLAB Executable) are a powerful feature that allows users to integrate C, C++, or Fortran code directly into MATLAB. They enable calling compiled functions from MATLAB, which can significantly improve performance for computationally intensive tasks or allow access to external libraries not natively supported by MATLAB.
Question 9: Which function adds a color bar legend to a surface plot in MATLAB?
- colormap
- caxis
- colorlegend
- colorbar (Correct answer)
Correct answer: colorbar
colorbar displays a color scale bar alongside the current axes to indicate the data values mapped to colors.
Question 10: What does `repmat(A, 2, 3)` do to matrix A?
- Repeats each element 2 rows and 3 columns
- Tiles A into a 2×3 block grid (Correct answer)
- Creates a random 2×3 matrix based on A
- Resizes A to 2×3
Correct answer: Tiles A into a 2×3 block grid
`repmat(A, m, n)` replicates A in an m×n tiling pattern to create a larger matrix.
Question 11: Which MATLAB function creates a 3D surface plot from X, Y, Z grid data?
- plot3
- mesh
- fill3
- surf (Correct answer)
Correct answer: surf
surf creates a shaded 3D surface using X, Y, Z grid matrices, with face colors representing Z values by default.
Question 12: Which MATLAB function returns the number of elements in an array regardless of its dimensions?
- numel(A) (Correct answer)
- ndims(A)
- size(A)
- length(A)
Correct answer: numel(A)
`numel(A)` returns the total number of elements, equivalent to prod(size(A)).
Question 13: What is the fundamental difference in how MATLAB scripts and functions interact with the workspace?
- Scripts create a temporary workspace, while functions use the global workspace.
- Both scripts and functions operate in their own private workspaces, isolated from the base workspace.
- Functions can modify base workspace variables directly without using 'global', but scripts cannot.
- Scripts operate in the base (or caller's) workspace, while functions have their own private, local workspace. (Correct answer)
Correct answer: Scripts operate in the base (or caller's) workspace, while functions have their own private, local workspace.
A key distinction is that scripts execute as if you typed their commands directly into the Command Window, sharing and potentially modifying the base workspace. Functions, however, have their own isolated workspaces; data is passed in via arguments and returned via output variables, which prevents unintended side effects on the base workspace.
Question 14: What does the semicolon (;) do when placed at the end of a MATLAB statement?
- Adds a comment
- Suppresses output to the Command Window (Correct answer)
- Ends the script
- Separates matrix rows
Correct answer: Suppresses output to the Command Window
A semicolon at the end of a statement suppresses its output from being printed to the Command Window.
Question 15: If the workspace contains a variable `x = 10`, and you execute the command `load('my_data.mat')`, where `my_data.mat` also contains a variable named `x` with the value `50`, what will be the state of the workspace variable `x` after the command completes?
- The command will produce an error due to a name conflict.
- A new variable `x_1` will be created with the value `50`.
- The value of `x` will be overwritten and become `50`. (Correct answer)
- The value of `x` will remain `10`.
Correct answer: The value of `x` will be overwritten and become `50`.
When you load variables from a MAT-file, if a variable in the file has the same name as a variable already in the workspace, the `load` function will overwrite the existing variable with the one from the file.
Question 16: Given A is a 3x4 matrix, what is the size of `A' * A`?
- 4x3
- 3x4
- 4x4 (Correct answer)
- 3x3
Correct answer: 4x4
A' is 4x3, so A'*A is (4x3)*(3x4) = 4x4.
Question 17: What does `sprintf('%05.2f', 3.7)` return in MATLAB?
- ' 3.70'
- '3.700'
- '03.70' (Correct answer)
- '003.7'
Correct answer: '03.70'
The format '%05.2f' means total width 5, 2 decimal places, zero-padded, producing '03.70' for the value 3.7.
Question 18: Which MATLAB function creates a modal dialog that pauses execution until the user responds?
- waitfor
- pause
- hold
- uiwait (Correct answer)
Correct answer: uiwait
uiwait suspends execution of the calling function until the specified figure is closed or uiresume is called.
Question 19: Where do we need to store a function to call it in other programs?
- The bin folder (Correct answer)
- Desktop
- Anywhere
- The MATLAB folder
Correct answer: The bin folder
For a function to be callable from any program or location within MATLAB, it needs to be stored in a directory that is on MATLAB's search path. The `bin` folder (or any folder added to the MATLAB path) is a common location for user-defined functions to ensure they are accessible globally without needing to change the current directory.
Question 20: How do you convert a character array `'hello'` to a string object in MATLAB R2016b+?
- char2str('hello')
- text('hello')
- str('hello')
- string('hello') (Correct answer)
Correct answer: string('hello')
The `string()` function converts character arrays, cell arrays of chars, and other types to string objects.
Question 21: Which MATLAB function directly computes the signal-to-noise ratio (SNR) in dB of a measured signal relative to a reference?
- noise(x, ref)
- snr(x, ref) (Correct answer)
- signalpower(x)
- ratio(x, ref)
Correct answer: snr(x, ref)
`snr(x, ref)` computes the SNR in dB by comparing the power of the reference signal to the power of the noise (x minus ref).
Question 22: Which MATLAB function returns both eigenvalues and eigenvectors of a matrix A?
- eigvec(A)
- spectrum(A)
- [V, D] = eig(A) (Correct answer)
- eig(A) with one output
Correct answer: [V, D] = eig(A)
With two output arguments, eig returns V (eigenvectors as columns) and D (diagonal matrix of eigenvalues).
Question 23: How do you create a 1x3 struct array named `s` with field `name` in MATLAB?
- s = struct(['Alice','Bob','Carol'])
- s.name = {'Alice','Bob','Carol'}
- s = struct('name', {'Alice','Bob','Carol'}) (Correct answer)
- s = {struct('name','Alice'), struct('name','Bob'), struct('name','Carol')}
Correct answer: s = struct('name', {'Alice','Bob','Carol'})
Passing a cell array of values to `struct()` automatically creates a struct array with one element per cell.
Question 24: What is the output of `sum(eye(4))` in MATLAB?
- 16
- [1 1 1 1] (Correct answer)
- 4
- [4 0 0 0]
Correct answer: [1 1 1 1]
sum operates column-wise by default; each column of eye(4) has exactly one 1, so the result is [1 1 1 1].
Question 25: Which MATLAB function designs a Chebyshev Type I IIR lowpass filter with ripple Rp dB in the passband?
- fir1(n, Wn)
- ellip(n, Rp, Rs, Wn)
- cheby1(n, Rp, Wn) (Correct answer)
- butter(n, Wn)
Correct answer: cheby1(n, Rp, Wn)
`cheby1(n, Rp, Wn)` designs a Chebyshev Type I filter that has equiripple in the passband and a monotonic stopband response.
Question 26: In MATLAB, what does `reshape(1:12, 3, 4)` produce?
- An error because 1:12 is a row vector
- A 12x1 vector
- A 4x3 matrix filled row-by-row
- A 3x4 matrix filled column-by-column (Correct answer)
Correct answer: A 3x4 matrix filled column-by-column
reshape fills the output matrix column-by-column from the input data, producing a 3x4 matrix.
Question 27: In App Designer, which layout component automatically arranges child components in rows and columns?
- FlowLayout
- TableLayout
- PanelLayout
- GridLayout (Correct answer)
Correct answer: GridLayout
GridLayout divides the parent container into a grid and children are placed in specified row/column positions.
Question 28: What does the MATLAB expression `A(:, 2)` return for a 3×4 matrix A?
- A 1×4 row vector
- The second row of A
- The second column of A (Correct answer)
- A scalar at position (2,2)
Correct answer: The second column of A
The colon in the row index selects all rows, so `A(:, 2)` returns the entire second column as a column vector.
Question 29: Which MATLAB function computes the determinant of a square matrix?
- inv(A)
- det(A) (Correct answer)
- rank(A)
- trace(A)
Correct answer: det(A)
`det(A)` computes the determinant of square matrix A.
Question 30: A function `calculateArea` is defined as follows: ```matlab function area = calculateArea(width, height) if nargin == 1 % Assume a square if only one input is given height = width; end area = width * height; end ``` What is the output of the command `calculateArea(5)`?
- 25 (Correct answer)
- 0
- Error: Not enough input arguments.
- 5
Correct answer: 25
The function is called with one argument, so the special variable `nargin` returns 1. The `if` condition evaluates to true, causing the `height` variable to be assigned the value of `width` (which is 5). The function then calculates `area = 5 * 5`, returning 25.
Question 31: In MATLAB, what is the output of `size([1 2 3; 4 5 6])`?
- [3 2]
- [1 2 3 4 5 6]
- 6
- [2 3] (Correct answer)
Correct answer: [2 3]
`size` returns a vector [rows, cols], so a 2×3 matrix returns [2 3].
Question 32: What does `kron(A, B)` compute in MATLAB?
- The Kronecker tensor product of A and B (Correct answer)
- Element-wise product of A and B
- The cross product of two vectors
- The outer product restricted to square matrices
Correct answer: The Kronecker tensor product of A and B
`kron(A, B)` computes the Kronecker product, replacing each element of A with that scalar times the entire matrix B.
Question 33: What is the purpose of the `pack` command in MATLAB?
- Saves variables to a ZIP file
- Compresses variables into a struct
- Defragments workspace memory by saving and reloading all variables (Correct answer)
- Packs a cell array into a matrix
Correct answer: Defragments workspace memory by saving and reloading all variables
`pack` consolidates fragmented workspace memory by saving all variables to disk and reloading them, which can free contiguous memory.
Question 34: A user has several variables in the workspace: `price_usd`, `price_eur`, `tax_rate`, and `quantity`. Which command would save only the variables related to price into a file named `prices.mat`?
- save('prices.mat', 'price_usd'; 'price_eur')
- save('prices.mat', 'price*') (Correct answer)
- save prices.mat price_usd, price_eur
- save prices.mat all(price)
Correct answer: save('prices.mat', 'price*')
The `save` function can use a wildcard character (*) to save variables that match a specific pattern. The command `save('prices.mat', 'price*')` correctly saves all variables whose names start with 'price'.
Question 35: In MATLAB, what does the `end` keyword represent when used as an array index?
- One past the last index (for slicing)
- It is a syntax error in indexing
- Zero (the first element)
- The last valid index of that dimension (Correct answer)
Correct answer: The last valid index of that dimension
When used inside indexing parentheses, `end` automatically resolves to the last index of the relevant array dimension.
Question 36: What does `rank(A)` return for a 4x4 identity matrix?
- 16
- 4 (Correct answer)
- 0
- 1
Correct answer: 4
The identity matrix has 4 linearly independent rows and columns, so its rank is 4 (full rank).
Question 37: Which App Designer callback fires when the value of a numeric edit field changes and the user presses Enter or clicks away?
- EditingFinishedFcn
- TextChangedFcn
- InputFcn
- ValueChangedFcn (Correct answer)
Correct answer: ValueChangedFcn
ValueChangedFcn triggers when the NumericEditField value is committed by the user pressing Enter or losing focus.
Question 38: What does the 'nargin' function return inside a MATLAB function?
- Number of input arguments provided by the caller (Correct answer)
- Number of optional arguments
- Number of output arguments
- Total number of defined parameters
Correct answer: Number of input arguments provided by the caller
'nargin' returns the number of input arguments actually passed by the caller at runtime.
Question 39: What is the key difference between the `who` and `whos` commands?
- `who` lists variables in the current function, while `whos` lists variables in the base workspace.
- `who` only lists variable names, while `whos` provides detailed information like size, bytes, and class. (Correct answer)
- `who` lists variables and their values, while `whos` only lists variable names.
- `who` is an obsolete function and has been replaced by `whos`.
Correct answer: `who` only lists variable names, while `whos` provides detailed information like size, bytes, and class.
The `who` command displays a simple list of the variables currently in the workspace. The `whos` command provides a more detailed list that includes the name, size, number of bytes, class, and other attributes for each variable.
Question 40: Which command writes a variable `result` from within a function into the base workspace?
- export result
- base.result = result
- global result
- assignin('base', 'result', result) (Correct answer)
Correct answer: assignin('base', 'result', result)
`assignin('base', 'result', result)` places the variable into the base workspace from within a function.
Question 41: Which of the following is an invalid variable name in MATLAB?
- _var (Correct answer)
- A_Var
- var_1
- VarA
Correct answer: _var
MATLAB variable names must begin with a letter, followed by letters, digits, or underscores. A variable name cannot start with an underscore.
Question 42: In MATLAB, what is the default data type for numeric values?
- int32
- single
- double (Correct answer)
- float
Correct answer: double
MATLAB stores numeric values as double-precision floating-point (double) by default unless explicitly specified otherwise.
Question 43: Which of the following creates a 3×3 identity matrix in MATLAB?
- ones(3)
- diag(3)
- eye(3) (Correct answer)
- identity(3)
Correct answer: eye(3)
eye(n) creates an n×n identity matrix with ones on the diagonal and zeros elsewhere.
Question 44: When using 'fread' to read binary data, what does the 'precision' argument control?
- The file seek position after reading
- The byte order (endianness) of the file
- The number of decimal places retained
- The data type of each value read from the file (Correct answer)
Correct answer: The data type of each value read from the file
The precision argument in fread specifies the data type (e.g., 'int16', 'float32', 'uint8') of each element to be read from the binary file.
Question 45: Which of the following is a valid MATLAB variable name?
- first-value
- 1stValue
- _myVar
- firstValue1 (Correct answer)
Correct answer: firstValue1
MATLAB variable names must start with a letter and contain only letters, digits, and underscores; `firstValue1` satisfies all rules.
Question 46: What does the MATLAB expression `A \ b` compute when A is a square matrix?
- The solution x to the linear system A*x = b (Correct answer)
- The left quotient b divided by A element-wise
- The inverse of A multiplied by b (always fails)
- Element-wise division of A by b
Correct answer: The solution x to the linear system A*x = b
The backslash operator solves the linear system A*x = b using efficient factorization, equivalent to inv(A)*b but numerically more stable.
Question 47: Which MATLAB function creates a filled contour plot?
- contourf (Correct answer)
- surf
- pcolor
- contour
Correct answer: contourf
contourf() creates a contour plot with filled regions between contour lines, using color to indicate value ranges.
Question 48: Which MATLAB function finds the minimum of an unconstrained multivariable function?
- fsolve
- fminsearch (Correct answer)
- optimize
- min
Correct answer: fminsearch
fminsearch uses the Nelder-Mead simplex algorithm to minimize a multivariable function without constraints.
Question 49: What does `numel(C)` return for a 2x3 cell array `C`?
- 3
- 2
- The total bytes used
- 6 (Correct answer)
Correct answer: 6
`numel()` returns the total number of elements, which for a 2x3 array is 2×3 = 6.
Question 50: Which MATLAB function concatenates two strings?
- join
- strcat (Correct answer)
- concat
- append
Correct answer: strcat
strcat concatenates character arrays or string arrays, removing trailing whitespace from character array inputs.
MATLAB Certification Exam
The MATLAB Certification Exam exam validates essential knowledge and skills required for certification or licensure in this field.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds
These practice questions were written with AI tools. They are not real exam questions. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy