Plotting the derivate of a compound function
2 views (last 30 days)
Show older comments
I have the following function made of f,f2,f3,f4,f5,f6 at the specific intervals. I tried storing the differential of the function inside a variable and then plotting it, but I dont get anything. Can anyone help me code another figure whereas I can plot all the derivates together?
clear, clc
syms x
x = [-400 -380 -350 -330 -300];
y = [15;16;27;26;25];
vander(x)
X = linsolve(vander(x),y);
plot (x,y,'ro')
hold on
f = @(x) X(5,1) +X(4,1)*x^1 +X(3,1)*x^2 +X(2,1)*x^3 +X(1,1)*x^4
fplot(f,[-400 -300])
hold on
%%
x2 = [-300 -290 -280 -270 -260 -250];
y2 = [25 28 29 27 26 29];
vander(x2)
X2 = linsolve(vander(x2),y2');
plot (x2,y2,'ro')
hold on
f2 = @(x) X2(6,1) +X2(5,1)*x^1 +X2(4,1)*x^2 +X2(3,1)*x^3 +X2(2,1)*x^4 +X2(1,1)*x^5 ;
fplot(f2,[-300 -250])
hold on
%%
x3 = [-250 -240 -230 -220 -210 -200];
y3 = [29 25 18 25 22 28];
vander(x3)
X3 = linsolve(vander(x3),y3');
plot (x3,y3,'ro')
hold on
f3 = @(x) X3(6,1) +X3(5,1)*x^1 +X3(4,1)*x^2 +X3(3,1)*x^3 +X3(2,1)*x^4 +X3(1,1)*x^5 ;
fplot(f3,[-250 -200])
hold on
%%
x4 = [-200 -190 -180 -170 -160 -150];
y4 = [28 27 21 26 23 25];
vander(x4)
X4 = linsolve(vander(x4),y4');
plot (x4,y4,'ro')
hold on
f4 = @(x) X4(6,1) +X4(5,1)*x^1 +X4(4,1)*x^2 +X4(3,1)*x^3 +X4(2,1)*x^4 +X4(1,1)*x^5 ;
fplot(f4,[-200 -150])
hold on
%%
x4 = [-150 -140 -130 -120 -110 -100];
y4 = [25 20 29 28 29 30];
vander(x4)
X4 = linsolve(vander(x4),y4');
plot (x4,y4,'ro')
hold on
f4 = @(x) X4(6,1) +X4(5,1)*x^1 +X4(4,1)*x^2 +X4(3,1)*x^3 +X4(2,1)*x^4 +X4(1,1)*x^5 ;
fplot(f4,[-150 -100])
hold on
%%
x5 = [-100 -90 -80 -70 -60 -50];
y5 = [30 24 24.5 24 25 22];
vander(x5)
X5 = linsolve(vander(x5),y5');
plot (x5,y5,'ro')
hold on
f5 = @(x) X5(6,1) +X5(5,1)*x^1 +X5(4,1)*x^2 +X5(3,1)*x^3 +X5(2,1)*x^4 +X5(1,1)*x^5 ;
fplot(f5,[-100 -50])
hold on
%%
x6 = [-50 -40 -30 -20 -10 0];
y6 = [22 20 21 20 21 22];
vander(x6)
X6 = linsolve(vander(x6),y6');
plot (x6,y6,'ro')
hold on
f6 = @(x) X6(6,1) +X6(5,1)*x^1 +X6(4,1)*x^2 +X6(3,1)*x^3 +X6(2,1)*x^4 +X6(1,1)*x^5 ;
fplot(f6,[-50 0])
hold on
xlim([-400 0])
ylim([0 40])
4 Comments
Walter Roberson
on 30 Oct 2019
f4d = @(x) X4(6,1)*0 +1*X4(5,1)*x.^0 +2*X4(4,1)*x.^1 +3*X4(3,1)*x.^2 +4*X4(2,1)*x.^3 +5*X4(1,1)*x.^4 ;
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!