MATLAB Environment and Syntax 4 — Questions and Answers
Question 1: Which MATLAB environment panel lets you navigate the file system and open files without typing full paths?
- Workspace browser
- Current Folder browser (Correct answer)
- Command History
- Variable Editor
Correct answer: Current Folder browser
The Current Folder browser provides a GUI file explorer that lets you browse directories and double-click files to open them.
Question 2: What does `isa(x, 'double')` return if `x` is a single-precision array?
- true (1)
- false (0) (Correct answer)
- NaN
- An error
Correct answer: false (0)
`isa()` returns logical 1 only when the object belongs to exactly the specified class; `single` does not match `'double'`.
Question 3: In the MATLAB Editor, what does Ctrl+Enter do (when the cursor is inside a Code Section)?
- Runs the entire script
- Runs only the current section (cell) (Correct answer)
- Inserts a new line
- Saves the file
Correct answer: Runs only the current section (cell)
Ctrl+Enter executes the code section (cell) delimited by `%%` markers where the cursor is currently located.
Question 4: What symbol creates a Code Section (cell) boundary in a MATLAB script?
- ## (double hash)
- %% (double percent) (Correct answer)
- -- (double dash)
- == (double equals)
Correct answer: %% (double percent)
Two consecutive percent signs `%%` at the start of a line define a section boundary in the MATLAB Editor.
Question 5: What does `eps` represent in MATLAB?
- Euler's number (≈2.718)
- Machine epsilon — the smallest difference between two double values (Correct answer)
- The empty string constant
- An error code placeholder
Correct answer: Machine epsilon — the smallest difference between two double values
`eps` is the machine epsilon for double precision, approximately 2.22e-16, representing floating-point relative precision.
Question 6: How do you concatenate two strings `s1` and `s2` in MATLAB (character array style)?
- s1 + s2
- s1 . s2
- [s1 s2] (Correct answer)
- strcat only
Correct answer: [s1 s2]
Horizontal concatenation with square brackets `[s1 s2]` joins character arrays directly; `strcat` also works but trims trailing whitespace.
Question 7: What does the `inputname` function return when used inside a MATLAB function?
- The name of the function itself
- The workspace name of a variable passed as an argument (Correct answer)
- The data type of the input
- The number of input arguments
Correct answer: The workspace name of a variable passed as an argument
`inputname(n)` returns the variable name used by the caller for the n-th input argument, useful for generating informative error messages.
Which MATLAB environment panel lets you navigate the file system and open files without typing full paths?