求f(x)x3-11.1x238.79x41.7690,在[0, 8]中的三个根。
function y=mj() for x0=0:0.01:8
x1=x0^3-11.1*x0^2+38.79*x0-41.769; if (abs(x1)<1.0e-8) x0 end end
2.血液中某药物浓度随时间的变化值: t(h) 0.25 0.5 1.0 1.5 2.0 3.0 4.0 6.0 8.0 C(mg19.30 18.15 15.36 14.10 12. 9.32 7.55 5.24 3.86/L) 求t=0.45, 1.75, 5.0, 6.0 时的浓度C.
分别用n=4,5,9的拉格朗日插值计算;并用样条函数插值计算,并比较结果。 拉格朗日插值:
function s=lagr(n)
x=[0.25 0.5 1.0 1.5 2.0 3.0 4.0 6.0 8.0 10.0];
y=[19.30 18.15 15.36 14.10 12. 9.32 7.55 5.24 3.86 2.88]; x0=[0.45 1.75 5.0 6.0]; m=length(x0); for i=1:m
D=abs(x-x0(i)); I=1;
while I<=n+1
for a=1:length(x) if D(a)==min(D) c(I)=a;
D(a)=max(D)+1; break
1
10.02.88 end end I=I+1; end b=sort(c); z=x0(i); t=0.0;
for k=1:length(b) u=1.0;
for j=1:length(b) if j~=k
u=u*(z-x(b(j)))/(x(b(k))-x(b(j))); end end
t=t+u*y(b(k)); end s(i)=t; end
样条函数差值:
Interp1(x,y,x0,’spline’) Spline(x,y,x0)
3.给定某药物浓度随时间的变化值,1)分别采用样条函数和三点公式(设h=0.1)求结点处的导数值,并比较结果。2)求该时间段的平均浓度(定步长S法) 样条函数:
x=[0.25 0.5 1.0 1.5 2.0 3.0 4.0 6.0 8.0 10.0];
y=[19.30 18.15 15.36 14.10 12. 9.32 7.55 5.24 3.86 2.88]; pp=csape(x,y,'not-a-knot'); df=fnder(pp); df1=ppval(df,x)
三点公式:
function df=sandian()
t=[0.25 0.5 1.0 1.5 2.0 3.0 4.0 6.0 8.0 10.0];
c=[19.30 18.15 15.36 14.10 12. 9.32 7.55 5.24 3.86 2.88]; h=0.1;n=length(t); for i=1:n x0=t(i); y0=c(i);
y1=spline(t,c,x0+h); y2=spline(t,c,x0+2*h);
2
y3=spline(t,c,x0-h); y4=spline(t,c,x0-2*h); switch i case 1
df(i)=(-3*y0+4*y1-y2)/(2*h); case n
df(i)=(y4-4*y3+3*y0)/(2*h); otherwise
df(i)=(y1-y3)/(2*h); end end end
平均浓度:
function averagec=simpson()
t=[0.25 0.5 1.0 1.5 2.0 3.0 4.0 6.0 8.0 10.0];
c=[19.30 18.15 15.36 14.10 12. 9.32 7.55 5.24 3.86 2.88]; m=(t(1)+t(10))/2; y=spline(t,c,m);
averagec=(c(1)+4*y+c(10))/6; end
4.计算:
(x4)2 f(x)1e2,0x8;108
2x=0:8;
y=1./(sqrt(2.*pi)).*exp(-(x-4).^2./2); z=trapz(x,y)
function y=jifen(x)
y=1./(sqrt(2.*pi)).*exp(-(x-4).^2./2);
q1=quad('jifen',0,8,1.0e-8) q2=quadl('jifen',0,8,1.0e-8)
5.大肠杆菌比生长速率测定。
在一定培养条件下,培养大肠杆菌,实验数据如下表。求:该条件下,大肠杆菌的最大比生长速率μm,半饱和常数Ks,并作模型检验。 S(mg/L) μ (h-1) S(mg/L) μ 3
h-1) ( 6 0.06 122 13 0.12 153 33 0.24 170 40 0.31 221 0.43 210 102 0.53 s=[6 13 33 40 102 122 153 170 221 210]; mu=[0.06 0.12 0.24 0.31 0.43 0.53 0.60 0.66 0.69 0.70 0.73];spmu=s./mu;n=length(s); a=polyfit(s,spmu,1); mum=1/a(1) ks=a(2)/a(1)
lxx=sum(s.^2)-1/n*(sum(s))^2; lyy=sum(spmu.^2)-1/n*(sum(spmu))^2; lxy=sum(s.*spmu)-1/n*sum(s)*sum(spmu);
r=lxy/(sqrt(lxx*lyy)) R=corrcoef(s,spmu)
Qr=lxy^2/lxx;
Q=(lxx*lyy-lxy^2)/lxx; F=Qr/(Q/(n-2))
6.多元线性回归
Pa=[9.0 8.6 8.4 7.5 7.0 6.8 6.5 6.0]'; Pb=[8.3 7.0 6.2 4.2 3.9 3.5 2.6 2.2]'; Pc=[2.7 4.4 5.4 8.3 9.1 9.7 10.9 11.8]'; r=[1.97 1.05 0.73 0.25 0.18 0.13 0.07 0.04]'; k0=ones(8,1);alpha=0.05; r0=log(r); Pa0=log(Pa); Pb0=log(Pb);
4
0.60 0.66 0.69 0.70 0.73 Pc0=log(Pc); p=[k0 Pa0 Pb0 Pc0];
[b,bint,r,rint,stats]=regress(r0,p,alpha) k=exp(b(1)) m=r'*r
p1=[Pa0 Pb0 Pc0]; stepwise(p1,r0)
7.作二次正交回归。
x1=[1 1 1 1 -1 -1 -1 -1 -1.68 1.68 0 0 0 0 0 0 0 0 0 0]'; x2=[1 1 -1 -1 1 1 -1 -1 0 0 -1.68 1.68 0 0 0 0 0 0 0 0]'; x3=[1 -1 1 -1 1 -1 1 -1 0 0 0 0 -1.68 1.68 0 0 0 0 0 0]';
y=[730.2 780.5 266.7 224.5 783.1 837.5 622.6 538.3 536.2 221.2 214.2 926.2 702.4 680.1 868.5 788.3 856.5 853.4 772.6 848.4]'; x=[x1 x2 x3];alpha=0.05; rstool(x,y,'linear',alpha)
5
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- jqkq.cn 版权所有 赣ICP备2024042794号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务