โ† All MATLAB Flashcard Decks

Programming and Scripting 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 Programming and Scripting flashcards as text
  1. Which MATLAB function converts a string to a number?

    Answer: str2double

    str2double converts a string representation of a number to a double-precision value.

  2. What is a cell array in MATLAB primarily used for?

    Answer: Storing heterogeneous data of different types and sizes

    Cell arrays can hold elements of different data types and sizes, unlike standard numeric arrays.

  3. In a MATLAB script, what does 'break' do inside a for loop?

    Answer: Exits the loop immediately

    'break' immediately terminates the innermost loop and transfers control to the statement after it.

  4. Which syntax correctly accesses the element in row 2, column 3 of matrix M?

    Answer: M(2,3)

    MATLAB uses parentheses with comma-separated indices to access matrix elements.

  5. What does 'varargin' allow in a MATLAB function definition?

    Answer: Variable number of input arguments

    'varargin' collects any number of additional input arguments into a cell array.

  6. Which MATLAB function checks if a variable exists in the current workspace?

    Answer: exist()

    exist('varname','var') returns 1 if the variable exists in the current workspace.

  7. What is the difference between '==' and 'isequal()' in MATLAB?

    Answer: '==' does element-wise comparison returning an array; isequal() returns a scalar true/false

    '==' returns a logical array of element-wise comparisons, while isequal() returns a single logical value indicating whether inputs are identical.