www.pudn.com > Weight_LS.rar > abc_estimate.m, change:2016-03-01,size:673b


%  
%   估计参数a、b、c的值 
%   [x,x_error,x_p]=ls_estimate(H,z,R,v) 
%  
%   Copyright (C) 2016 SCA 
%  
 
function abc_estimate 
 
clc; 
clear all; 
 
z = [2.9828,4.525,6.1155,7.234,8.4329,9.1259,10.1800,10.8600,10.9300,11.1410,... 
   10.6090,10.4800,10.3830,9.5808,8.4611,7.4678,6.3942,4.1592,3.0029,0.5503]'; 
x_ture=[-0.1,2,1]'; 
for t=1:size(z,1) 
    H(t,:) = [t^2,t,1]; 
end 
 
w=rand(size(z,2),1);%量测噪声 
R=diag(randn(size(z,1),size(z,2)));%量测误差扩维向量 
 
[x,x_error,x_p] = ls_estimate(H,z,w,R);%最小二乘估计 
disp(x); 
t=1:size(z,1); 
plot(t,z,'r-o',t,H*x,'b-*',t,H*x_ture,'c-s'); 
legend('量测数据','估计值','真实值'); 
title('最小二乘法的批处理实现');