โ† All MATLAB Flashcard Decks

General MCQ 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 General MCQ flashcards as text
  1. In MATLAB, an array's index begins with

    Answer: 1

    Unlike many other programming languages (like C++ or Python) where array indexing starts at 0, MATLAB uses 1-based indexing. This means the first element of any array or matrix is accessed using an index of 1.

  2. What is the return type of the function of the angle in MATLAB?

    Answer: Radians

    In MATLAB, most built-in trigonometric and angle-related functions, such as `angle()`, `sin()`, `cos()`, `atan()`, etc., operate with angles specified in radians by default. If degrees are required, specific functions like `sind()`, `cosd()`, or conversion factors must be used.

  3. What is the use of the abs function in Matlab?

    Answer: Returns magnitude of a number

    The `abs` function in MATLAB calculates the absolute value of a number. For real numbers, this represents its magnitude without regard to its sign. For complex numbers, `abs` returns the complex modulus, which is the Euclidean distance from the origin in the complex plane and also represents its magnitude.

  4. What will be the output of atan2(-1,1) in Matlab?

    Answer: 0.7854

    The `atan2(y, x)` function in MATLAB calculates the four-quadrant inverse tangent of `y/x`, returning an angle in radians. While `atan2(-1,1)` typically yields -0.7854 (representing -pi/4 radians for the point (1,-1)), the provided correct answer of 0.7854 corresponds to `atan2(1,1)`. This value represents pi/4 radians, which is the angle for a point (1,1) in the first quadrant.

  5. In a fprintf statement, what character is used to print a new line?

    Answer: \n

    In MATLAB's `fprintf` function, the `\n` character is a special escape sequence used to insert a newline. When `fprintf` encounters `\n`, it moves the cursor to the beginning of the next line. This ensures that any subsequent output appears on a new line, making the output more readable and structured.

  6. How to clear the command window in Matlab?

    Answer: Clc

    The `clc` command in MATLAB is used to clear the command window. It removes all previous commands and their outputs from the display, providing a clean interface. This command only affects the visual display and does not clear variables from the workspace or modify the command history.

  7. What does A = [1 0 2]; b = [3 0 7]; and c=a.*b; produce?

    Answer: [3 0 14]

    In MATLAB, the `.*` operator performs element-wise multiplication between two matrices or vectors of the same size. For `A = [1 0 2]` and `b = [3 0 7]`, `c = a.*b` multiplies corresponding elements: `(1*3)`, `(0*0)`, and `(2*7)`. This operation results in the vector `[3 0 14]`.