赞
踩
function zhishunihe
%y_nh=a*e^(b*x)
%转化为:lny=lna+bx
clear
clc
x=[1,2,3,4,5,6,7,8,9,10];
y=[2615,1943,1494,1087,765,538,484,290,226,204];
% plot(x,y,'*');
m=length(x);
% n=4;
s_x=0;
s_xx=0;
s_y=0;
s_xy=0;
pc=0;
for i=1:m
%求解X矩阵的元素
s_x=s_x+x(i);
s_xx=s_xx+x(i).*x(i);
%求解Y矩阵的元素
s_y=s_y+log(y(i));
s_xy=s_xy+x(i).*log(y(i));
end
X=[m,s_x,;s_x,s_xx];
Y=[s_y,s_xy]';
%求解系数
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。