Bird
0
0

You have data x = [0 1 2 3 4] and y = [0 1 4 9 16]. How do you interpolate the square root of 5 using interp1?

hard📝 Application Q8 of 15
MATLAB - Numerical Methods
You have data x = [0 1 2 3 4] and y = [0 1 4 9 16]. How do you interpolate the square root of 5 using interp1?
AUse <code>interp1(x, y, sqrt(5), 'linear')</code> to find y at sqrt(5)
BUse <code>interp1(x, y, 5, 'spline')</code> to estimate y at x=5
CUse <code>interp1(y, x, 5, 'linear')</code> to find x for y=5
DUse <code>interp1(x, y, 5, 'nearest')</code> to find y at 5
Step-by-Step Solution
Solution:
  1. Step 1: Understand the problem

    To approximate sqrt(5) (~2.236) using interpolation on y = x^2 table, perform inverse interpolation: find x where y=5.
  2. Step 2: Choose correct syntax

    Use interp1(y, x, 5, 'linear') to find x at y=5.
  3. Final Answer:

    Use interp1(y, x, 5, 'linear') to find x for y=5 -> Option C
  4. Quick Check:

    Inverse interp1(y, x, 5) ≈ sqrt(5) [OK]
Quick Trick: Inverse interp1(y, x, 5, 'linear') for sqrt(5) [OK]
Common Mistakes:
  • Using direct interp1(x, y, sqrt(5))
  • Querying at x=5 instead of y=5
  • Using wrong method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes