clear
syms t y a
y7=fvvar([-5000 -5000 -5000 -5000 1500 1500
4000],0.0558);
y8=fvvar([-5000 -5000 -5000 -5000 1500 1500
4000 4000],0.0558);
y9=fvvar([-5000 -5000 -5000 -5000 1500 1500
4000 4000 4000],0.0558);
y10=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000],0.0558);
y11=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000],0.0558);
y12=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000],0.0558);
y13=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000 4000],0.0558);
y14=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000 4000 4000],0.0558);
y15=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000 4000 4000 4000],0.0558);
y16=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000],0.0558);
y17=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000],0.0558);
y18=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000],0.0558);
y19=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000],0.0558);
y20=fvvar([-5000 -5000 -5000 -5000 1500
1500 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000 4000
4000],0.0558);
if
y7>0
disp('t=7');
else if y8>0
disp('t=8');
else if y9>0
disp('t=9');
else if y10>0
disp('t=10');
else if y11>0
disp('t=11');
else if y12>0
disp('t=12');
else if y13>0
disp('t=13');
else if y14>0
disp('t=14');
else if y15>0
disp('t=15');
else if y16>0
disp('t=16');
else if y17>0
disp('t=17');
else if y18>0
disp('t=18');
else if y19>0
disp('t=19');
else if y20>0
disp('t=20');
else
disp('no answer');
end
fprintf('第20年的未来值为%d\n',y20);
a7=4000/(7000-y7)*100%;
a8=4000/(11000-y8)*100%;
a9=4000/(15000-y9)*100%;
a10=4000/(19000-y10)*100%;
a11=4000/(23000-y11)*100%;
a12=4000/(27000-y12)*100%;
a13=4000/(31000-y13)*100%;
a14=4000/(35000-y14)*100%;
a15=4000/(39000-y15)*100%;
a16=4000/(43000-y16)*100%;
a17=4000/(47000-y17)*100%;
a18=4000/(51000-y18)*100%;
a19=4000/(54000-y19)*100%;
a20=4000/(59000-y20)*100%;
x0=[7 8 9 10 11 12 13 14 15 16 17 18 19
20];
a0=[a7 a8 a9 a10 a11 a12 a13 a14 a15 a16
a17 a18 a19 a20];
x=7:20;
a=spline(x0,a0,x);
figure
plot(x,a)