MATLAB String Operations and File I/O Flashcards
6 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 6 MATLAB String Operations and File I/O flashcards as text
Which MATLAB function checks if two strings are equal?
Answer: strcmp
strcmp returns 1 (true) if two strings are identical and is case-sensitive, unlike strcmpi which ignores case.
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.
How do you close a file in MATLAB after using fopen?
Answer: fclose(fid)
fclose closes the file associated with the given file identifier and returns 0 on success.
What function imports data from a space-delimited text file into a matrix in MATLAB?
Answer: All of the above can work
MATLAB provides multiple ways to load text data: load for simple ASCII files, dlmread for delimited files, and readmatrix as the modern replacement.
What does `sprintf('%05.2f', 3.7)` return in MATLAB?
Answer: '03.70'
The format '%05.2f' means total width 5, 2 decimal places, zero-padded, producing '03.70' for the value 3.7.
Which MATLAB function trims leading and trailing whitespace from a string?
Answer: strtrim
strtrim removes leading and trailing whitespace (spaces, tabs, newlines) from a character array or string.