evaluate a cubic polynomial in an interval

3 visualizzazioni (ultimi 30 giorni)
Max
Max il 20 Nov 2012
Hi at everybody,
I have to evaluate a cubic polynomial in an interval;
I have a polynomials coefficients vector (C) in the form
v1= ( a1 * x^3 ) + ( b1 * x^2 ) + ( c1*x ) + (d1)
and the interval [i_k , i_(k+1)]
Is there a command to do this?
thanks
  2 Commenti
Matt Fig
Matt Fig il 20 Nov 2012
You don't show vector C. Is C like this:
C = [a1 b1 c1 d1];
or what?
Max
Max il 20 Nov 2012
Sorry, I forgot a step ;) Yes

Accedi per commentare.

Risposte (2)

John Petersen
John Petersen il 20 Nov 2012
If you mean you want to evaluate v1 at x values between the kth and (k+1)th values of x, then define x as the interval of interest, define an array for your coefficients and then use polyval to evaluate the polynomial at the values of x you have specified. You can plot the result to see if it's what you expected.
x = [starting_value:stepsize:ending_value];
c = [a1 b1 c1 d1];
v1 = polyval(c,x);
figure;plot(x,v1)

Max
Max il 20 Nov 2012
I try to be more explicit:
I have to calculate the inflection point of a cubic spline.
I have 2 vectors that contains experimental data; - temperature - - > temp = [t1 t2 t3 ... t7 ] - deepness (depth); - - > deep = [d1 d2 d3 ... d7]
with :
pp=spline(deep,temp);
I generate the spline; with :
[x,C,l,k,d]=unmkpp(pp);
I extrapolated the coefficient of spline in the C matrix: ervery rows represents a interpolating polynomial ( f(x) = ax^3 + bx^2 + cx + d);
To identify the inflection point, I calculate (first the first derivatives and then) the second derivative of the spline coefficients ( the polynomial derivatives is f''(x) = 6ax + 2b )
CoefDer2 = [6*C(:,1) 2*C(:,2)];
Cder2 = mkpp(x,CoefDer2);
Then, I impose f''(x)=0 and calculate all polynomials roots
xCder2 = cell2mat(arrayfun(@(X) roots(Cder2(X,:)), (1:size(Cder2,1)),'un',0))';
Now in xCder2 (vector) there are memorized all the x-components of the probable inflection points.
at this point I have to evaluate every polynomial in its interval:
for example, evaluate xCder2(1), in the interval (deep(1), deep(2)) xCder2(2), in the interval (deep(2), deep(3)) etc

Categorie

Scopri di più su Polynomials in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by