Environment and Syntax 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 Environment and Syntax flashcards as text
What does the `path` command do in MATLAB?
Answer: Displays or modifies the MATLAB search path
The `path` command displays the current MATLAB search path and can be used to add or remove directories from it.
In MATLAB, what is the difference between a script and a function file?
Answer: Functions have their own workspace; scripts share the base workspace
Functions operate in their own local workspace and can accept inputs/outputs, while scripts run in the base workspace.
What does `format long` do in MATLAB?
Answer: Displays numbers with 15 significant digits
`format long` switches numeric display to 15 significant digits instead of the default 5 (`format short`).
How do you add a comment to a MATLAB script?
Answer: Use % before the comment text
The percent sign `%` begins a single-line comment in MATLAB; everything after it on that line is ignored.
What is the output of `class(uint8(5))` in MATLAB?
Answer: uint8
`class()` returns the data type of a variable as a string, so `class(uint8(5))` returns `'uint8'`.
Which MATLAB function opens the built-in documentation browser for a specific function?
Answer: doc
`doc functionName` opens the full HTML documentation page in the MATLAB Help browser, while `help` shows text-only docs in the Command Window.
What is the MATLAB operator for element-wise multiplication of two arrays?
Answer: .*
The `.*` operator multiplies arrays element by element, whereas `*` performs matrix multiplication.