Bird
0
0

Given x = [2 4 6 8] and y = [5 15 25 35], what is the output of interp1(x, y, 5) in MATLAB?

medium📝 Predict Output Q4 of 15
MATLAB - Numerical Methods
Given x = [2 4 6 8] and y = [5 15 25 35], what is the output of interp1(x, y, 5) in MATLAB?
A20
B22.5
C25
D15
Step-by-Step Solution
Solution:
  1. Step 1: Identify the interval

    5 lies between 4 and 6 in vector x.
  2. Step 2: Perform linear interpolation

    At x=4, y=15; at x=6, y=25. The slope is (25-15)/(6-4) = 5.
  3. Calculate y at x=5

    y = 15 + 5*(5-4) = 15 + 5 = 20.
  4. Final Answer:

    20 -> Option A
  5. Quick Check:

    Check linear interpolation formula [OK]
Quick Trick: Find interval and apply linear interpolation formula [OK]
Common Mistakes:
  • Using wrong interval points
  • Forgetting linear interpolation formula
  • Mixing up x and y values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes