误差理论与数据处理实验报告

fprintf('当正应力x=24.5pa时,抗剪估计值y=%.3f\\n',y1)

2、程序:

x=[150 200 250 300]';

y1=[77.4 76.7 78.2;84.1 84.5 83.7;88.9 89.2 89.7;94.8 94.7 95.9;]; y=[0 0 0 0]'; for i=1:4

y(i,1)=(y1(i,1)+y1(i,2)+y1(i,3))/3; end

A=[ones(size(x)),x];

[ab,tm1,r,rint,stat] = regress(y,A); a=ab(1);b=ab(2);r2=stat(1); alpha=[0.05,0.01]; yhat=a+b*x;

disp(['y对x的线性回归方程为:y=',num2str(a),'+',num2str(b),'x']) SSR=(yhat-mean(y))'*(yhat-mean(y)); SSE=(yhat-y)'*(yhat-y);

SST=(y-mean(y))'*(y-mean(y)); n=length(x);

Fb=SSR/SSE*(n-2);

Falpha=finv(1-alpha,1,n-2); table=cell(4,7);

table(1,:)={'方差来源','偏差平方和','自由度','方差','F比','Fα','显著性'}; table(2,1:6)={'回归',SSR,1,SSR,Fb,min(Falpha)};

table(3,1:6)={'剩余',SSE,n-2,SSE/(n-2),[],max(Falpha)}; table(4,1:3)={'总和',SST,n-1}; if Fb>=max(Falpha)

table{2,7}='高度显著';

elseif (Fb=min(Falpha)) table{2,7}='显著'; else

table{2,7}='不显著'; end

8

table

9

3、程序

x=[12 13 14 15 16 18 20 22 24 26];

y=[52.0 55.0 58.0 61.0 65.0 70.0 75.0 80.0 85.0 91.0]; plot(x,y,'*k') title('散点图');

X=[ones(size(x')), x']; b= regress(y',X,0.05);

disp(['y随x变化的经验公式为:y=',num2str(b(1)),'+',num2str(b(2)),'x'])

10

11

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4