Bird
0
0

What will be the output of this MATLAB code?

medium📝 Predict Output Q5 of 15
MATLAB - Numerical Methods
What will be the output of this MATLAB code?
f = @(x) x.^3;
result = integral(f, 1, 2);
disp(round(result,2));
A2.75
B3.50
C4.00
D3.75
Step-by-Step Solution
Solution:
  1. Step 1: Calculate integral of x^3 from 1 to 2

    Integral of x^3 dx = (x^4)/4, evaluate from 1 to 2 = (2^4)/4 - (1^4)/4 = (16/4) - (1/4) = 15/4 = 3.75
  2. Step 2: Check rounding

    Result is 3.75, rounding to 2 decimals remains 3.75
  3. Final Answer:

    3.75 -> Option D
  4. Quick Check:

    Integral of x^3 from 1 to 2 = 3.75 [OK]
Quick Trick: Integral of x^n is x^(n+1)/(n+1) [OK]
Common Mistakes:
  • Forgetting to divide by n+1
  • Incorrect limits evaluation
  • Rounding errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes