Max and Min Slopes
Show older comments
Hi,
I am constructing two segments of cubic hermite functions. How can find the maximun and mininmum slopes of the curve and plot them graphically in the order of magnitude?
% first segment
%Inputs:
%first point (0,0); second point(5,150); thid points(10,0)
%derivatives: g0=g1=g2=0
x0=0; x1=5; g0=0; g1=0;
y0= 0; y1= 150;
A1 = [x0^3,x0^2,x0,1;
3*x0^2,2*x0,1,0;
x1^3,x1^2,x1,1;
3*x1^2,2*x1,1,0];
C1 = A1\[y0,g0,y1,g1]'; % Solve for the four cubic Hermite coefficients
n = 1000;
X1 = linspace(x0,x1,n);
Y1 = C1'*[X1.^3;X1.^2;X1;ones(1,n)];
% second segment
x2=10; y2= 0; g1= 0; g2=0;
A2 = [x1^3,x1^2,x1,1;
3*x1^2,2*x1,1,0;
x2^3,x2^2,x2,1;
3*x2^2,2*x2,1,0];
C2 = A2\[y1,g1,y2,g2]';
X2 = linspace(x1,x2,n);
Y2 = C2'*[X2.^3;X2.^2;X2;ones(1,n)];
plot(X1,Y1);hold on; plot(X2,Y2);title('cubic hermite'); xlabel('x'); ylabel('y');
Accepted Answer
More Answers (0)
Categories
Find more on Language Fundamentals 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!