Basic Introduction 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 Basic Introduction flashcards as text
What symbol is used to start a comment in a MATLAB script?
Answer: %
The percent sign (%) starts a comment in MATLAB; everything after it on the same line is ignored.
Which of the following creates a 3×3 identity matrix in MATLAB?
Answer: eye(3)
eye(n) creates an n×n identity matrix with ones on the diagonal and zeros elsewhere.
What is the result of logical expression (3 > 2) in MATLAB?
Answer: Both 'true' and 1
MATLAB returns logical 1 for true comparisons; logical 1 and the string 'true' are equivalent representations.
Which MATLAB function computes the square root of a number?
Answer: sqrt(x)
sqrt(x) is the dedicated MATLAB function for computing the square root of x.
How does MATLAB index arrays — starting from 0 or 1?
Answer: 1, unlike most languages
MATLAB arrays are 1-indexed, meaning the first element is at index 1, not 0.
What does the command 'who' display in MATLAB?
Answer: A list of variable names in the workspace
who lists the names of all variables currently defined in the MATLAB workspace.
In MATLAB, what is the difference between '==' and '='?
Answer: '=' assigns a value; '==' tests equality
The single '=' is the assignment operator, while '==' is the relational equality comparison operator.