How to plot trajectory curve given x and y points as well as minima and maxima of the polynomial?
18 views (last 30 days)
Show older comments
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
How do I set the derivative to zero for the min and max points in my plot?
0 Comments
Answers (2)
KSSV
on 16 Dec 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
Image Analyst
on 16 Dec 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 Comments
Image Analyst
on 17 Dec 2019
Did you use the max() and min() functions? Like for example this:
maxValue = max(ys_deriv);
If not, then why not?
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!