MATLAB CODE:
Matlab’s polyder() and polyint() functions return the derivative and integral of a polynomial, respectively. For example, polyder([4 -2 3 7 -5]) yields [16 -6 6 7] in other words: d/dx{4x4−2x3 +3x2+7x−5} = 16x3−6x2 +6x+7and,polyint([16 -6 6 7]) yields [4 -2 3 7 0] note the zero at the end. in other words:∫(16x3-6x2+6x+7)=4x4–2x3+ 3x2+7x+? where C = 0
As seen above, the constant of integration is always assumed to be zero when using polyint().While polyint() is available, using your knowledge of Matlab arrays (and basic calculus), you should be able to write a simple, single line statement – without using polyint() – which will also calculate an array with the coefficients of the integral of an arbitrary polynomial. To be explicit, suppose that p is an arbitrary array of any length defined in the Matlab workspace. If we then write intp = <stuff>; determine what <stuff> should be so that intp will be an array with the coefficients of the integral of the polynomial represented by p. For example if p=[16 -6 6 7] your calculation should give intp=[4 -2 3 7 0] (noting again that the constant of integration is zero). Try generating additional examples, with different length p arrays, and compare your code to the output of polyint() to verify the code. We will check your work with a different array p when you are ready, but you cannot change the statement you use to calculate intp when we check; your code must work unchanged with an entirely different, completely unknown array p. Use up-arrow to recall your previous statement after entering the new p.
I'm getting a little lost. I think I have majority of it but I'm not sure.
intp=[p./(length(p):-1:1) 0]
Get Answers For Free
Most questions answered within 1 hours.