How to plot trajectory curve given x and y points as well as minima and maxima of the polynomial?

19 visualizaciones (últimos 30 días)
I've spent hours trying to figure out how to do this in matlab, which is frusturating considering it was so easy to find the solution by hand:
The three position (horizontal, vertical) points (0,80), (120,0), (140,5) were given in the word problem; this data was used to create three equations using the polynomial template shown in equation one. Since the point (0,80) is the maximum of the slope and (120,0) is the minimum, the derivative of the height function at these tangent points is zero; this adds two more equations to the system. With a total of five equations, the resulting solution to the system is a fourth degree polynomial. The coefficients of this polynomial were calculated using matricies.
edit:
Here's what I've got so far
Capture1.PNG
How do I set the derivative to zero for the min and max points in my plot?

Respuestas (2)

KSSV
KSSV el 16 de Dic. de 2019
syms a b c d e ;
eqns = [e == 80 ;
207360000*a+1728000*b+1440*c+120*d+e == 0 ;
384160000*a+2744000*b+19600*c+140*d+e == 5 ;
d == 0 ;
6912000*a+43200*b+240*c+d==0] ;
S = solve(eqns,[a,b,c,d,e]) ;
S.a
S.b
S.c
S.d
S.e
  1 comentario
Newslin Heiller
Newslin Heiller el 16 de Dic. de 2019
I'm trying to do something more like this (Horner's Method for Evaluating Polynomials):
x0=[0 120 140];
y0=[80 0 5];
xs=linspace(0,1,150)
n=length(x0)-1;
ylim([0 100]);
pp_pchip=pchip(x0,y0);
coeffs_deriv = zeros(n,3);
for k = 1:n
c = pp_pchip.coefs(k,:);
coeffs_deriv(k,:) = polyder(c);
end
pp_deriv = mkpp(x0,coeffs_deriv);
clf;
ys_deriv = ppval(pp_deriv,xs);
ydata_deriv = ppval(pp_deriv,x0);
plot(xs,ys_deriv,'g','linewidth',2);
hold on;
plot(x0,ydata_deriv,'k.','markersize',30);
title('First derivative (pchip)','fontsize',18);

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 16 de Dic. de 2019
If you have x and y (hx), you can get the coefficients with polyfit like this
coefficients = polyfit(x, hx, 4);
Now you can get separate coefficients if you want to:
a = coefficients(1);
b = coefficients(2);
c = coefficients(3);
d = coefficients(4);
e = coefficients(5);
These are the same a, b, c, and d in both the h(x) and h'(x) equations, obviously.
  4 comentarios
Image Analyst
Image Analyst el 17 de Dic. de 2019
Did you use the max() and min() functions? Like for example this:
maxValue = max(ys_deriv);
If not, then why not?

Iniciar sesión para comentar.

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by