Mixed Deck — All MATLAB Topics Flashcards
100 cards from real MATLAB practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 20 Mixed Deck — All MATLAB Topics flashcards as text
Which function in MATLAB computes numerical integration using adaptive quadrature?
Answer: integral
The integral function uses adaptive Gauss-Kronrod quadrature to numerically integrate a function over a specified interval.
How do you load only the variable 'score' from 'results.mat' into the workspace?
Answer: Both A and B are valid
Both the command syntax `load results.mat score` and the function syntax `load('results.mat', 'score')` are valid in MATLAB.
Which of the following correctly accesses the element in row 2, column 3 of matrix M?
Answer: M(2,3)
MATLAB uses parentheses for indexing, so M(2,3) retrieves the element at row 2, column 3.
Which statement correctly defines a function that takes no inputs and returns no outputs in MATLAB?
Answer: function myFunc()
A zero-input, zero-output MATLAB function uses `function functionName()` with empty parentheses.
Which MATLAB function creates a 3D surface plot from X, Y, Z grid data?
Answer: surf
surf creates a shaded 3D surface using X, Y, Z grid matrices, with face colors representing Z values by default.
What is the role of the 'Tag' property in MATLAB UI components?
Answer: Provides a string identifier to locate the component with findobj
Tag is a user-defined string identifier that findobj can search for to retrieve a handle without storing it explicitly.
What does the tilde '~' symbol mean when used as a function output argument in MATLAB?
Answer: The output is ignored/discarded
Using '~' as a placeholder output argument tells MATLAB to discard that output without storing it.
What is the output of mod(10, 3) in MATLAB?
Answer: 1
mod(10, 3) returns 1, the remainder when 10 is divided by 3 (10 = 3×3 + 1).
Which MATLAB function is used to solve a system of linear equations Ax = b?
Answer: A \ b
The backslash operator A\b computes the solution to the linear system Ax=b efficiently without explicitly computing the inverse.
Which MATLAB command would you use to display a 2D matrix as an image with scaled color mapping?
Answer: imagesc
imagesc(C) displays matrix C as an image with the colormap scaled to span the full range of values in C.
In a MATLAB GUI, which function retrieves the value of a property from a UI object handle?
Answer: get
get(handle, 'PropertyName') returns the current value of the specified property for any graphics or UI object.
Which MATLAB function creates a toolbar button on a figure's toolbar?
Answer: uipushtool
uipushtool adds a push button to a uitoolbar object, which itself is attached to a figure.
In MATLAB, what does `norm(v)` compute for a vector v by default?
Answer: The L2 norm (Euclidean length)
By default, `norm(v)` computes the 2-norm (Euclidean norm), the square root of the sum of squared elements.
What does `regexp(str, pattern)` return in MATLAB?
Answer: Starting indices of matches of the regular expression pattern in str
regexp returns a vector of starting indices where the regular expression pattern matches within the input string.
Which keyboard shortcut recalls the previous command in the MATLAB Command Window?
Answer: Up arrow key
Pressing the Up arrow key cycles through command history in the MATLAB Command Window.
In a `switch` statement, what block handles all cases not matched by any `case`?
Answer: otherwise
The `otherwise` block in a MATLAB switch statement handles unmatched cases.
Which operator is used for element-wise multiplication in MATLAB?
Answer: .*
The '.*' operator performs element-by-element multiplication, unlike '*' which performs matrix multiplication.
What is `det` of the matrix [2 0; 0 3]`?
Answer: 6
For a diagonal 2x2 matrix, the determinant is the product of the diagonal elements: 2*3 = 6.
Which statement correctly defines a function handle in MATLAB?
Answer: f = @(x) x^2
The '@(x) x^2' syntax creates an anonymous function handle in MATLAB.
Given a table `T` created with the command `T = table([8; 10; 11], ["A"; "B"; "B"], 'VariableNames', {'Score', 'Group'})`. Which command correctly extracts the 'Score' value from the row where 'Group' is equal to "A"?
Answer: T.Score(T.Group == "A")
The expression `T.Group == "A"` creates a logical index `[1; 0; 0]`. Using this logical index to index into the 'Score' variable `T.Score` correctly selects only the elements where the condition is true, returning the value `8`.