Bird
0
0

Given the MATLAB code:

medium📝 Predict Output Q5 of 15
MATLAB - Numerical Methods
Given the MATLAB code:
f = @(t,y) t + y;
[t,y] = ode45(f, [0 1], 1);
disp(y(end));

What is the approximate value displayed?
A0.5
B1.0
C2.7
D3.5
Step-by-Step Solution
Solution:
  1. Step 1: Understand the ODE

    The equation is dy/dt = t + y with y(0)=1.
  2. Step 2: Recognize the solution behavior

    This is a linear ODE with increasing solution; the exact solution at t=1 is about 2.718 (e - 1 + 1).
  3. Step 3: Check code output

    ode45 numerically approximates this, so y(end) is close to 2.7.
  4. Final Answer:

    2.7 -> Option C
  5. Quick Check:

    Value near e (2.718) expected [OK]
Quick Trick: dy/dt = t + y grows near e at t=1 [OK]
Common Mistakes:
  • Assuming solution decreases
  • Confusing initial value
  • Ignoring exponential growth

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes