Bird
0
0

What is the output of interp1([1 3 5], [2 6 10], 4, 'nearest')?

medium📝 Predict Output Q5 of 15
MATLAB - Numerical Methods
What is the output of interp1([1 3 5], [2 6 10], 4, 'nearest')?
A4
B8
C10
D6
Step-by-Step Solution
Solution:
  1. Step 1: Understand 'nearest' interpolation

    It picks the y-value of the closest x point to 4.
  2. Step 2: Find nearest x to 4

    Nearest x is 3 (distance 1) and 5 (distance 1), MATLAB picks the smaller index, so 3.
  3. Step 3: Return y at x=3

    y = 6.
  4. Final Answer:

    6 -> Option D
  5. Quick Check:

    Nearest interp at 4 = 6 [OK]
Quick Trick: Nearest picks closest x's y value [OK]
Common Mistakes:
  • Averaging values
  • Picking farther point
  • Confusing with linear method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes