General MCQ Flashcards
7 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 7 General MCQ flashcards as text
What is the MATLAB syntax to access elements in a struct field named 'age' of variable 'person'?
Answer: person.age
MATLAB uses dot notation to access struct fields, so person.age retrieves the 'age' field of the struct 'person'.
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.
What does the function cell2mat do in MATLAB?
Answer: Converts a cell array of matrices into a single matrix
cell2mat concatenates the contents of a cell array of numeric arrays into a single numeric matrix.
In MATLAB, which loop type checks the condition AFTER executing the loop body at least once?
Answer: MATLAB has no such loop
MATLAB does not have a built-in do-while loop; both for and while loops check their conditions before each iteration.
What is the purpose of the 'nargin' variable inside a MATLAB function?
Answer: Number of input arguments passed to the function
nargin returns the number of input arguments provided by the caller, allowing functions to handle optional inputs.
Which MATLAB function applies a given function to each element of an array and returns the results?
Answer: arrayfun
arrayfun applies a function to each element of an array and collects the results into an output array of the same size.
What does the MATLAB function 'reshape(A, m, n)' do?
Answer: Rearranges elements of A into an m×n matrix without changing data
reshape rearranges the elements of A column-by-column into a new matrix of size m×n; the total number of elements must remain the same.