The Student Room Group

Matlab

Hi everyone I have a question to do on matlab and I am finding it difficult to answer after trying various ways.

The question is:
Develop a MATLAB user defined function that determines the definite integral
of a polynomial. The function will be of the form function G =
polyintegral(v,x0,x1) where x0 and x1 are the lower and upper limits of
integration and v is a vector of the polynomial coefficients so that the
polynomial is given by

y=v1+v2x+v3x^2+...vn+1x^n

Test your function by determining the value of

integrate with limits 3 and -2: 2+6.7x+4x^2-3x^3+1.5x-x^6dx

HINT: You can easily inegrate x^n - it is equal to x^n+1/n+1. Then evaluate ot between limits.
Consider what you want to come out at the end of the integration.

I would suggest writing it out by hand first before you try implementing it in MATLAB.

Quick Reply

Latest