You are on page 1of 2

clear all;

clc;
z=[9.01
3.02
6.98
4.40];
disp('z=');
disp(z);
w=[100 0 0 0
0 100 0 0
0 0 50 0
0 0 0 50];
disp('w=');
disp(w);
h=[0.625 -0.125
-0.125 0.625
0.375 0.125
0.125 0.375];
disp('h=');
disp(h);
e=1;
while(e>0.001)
g=h'*w*h;
g1=h'*w*z;
X=(inv(g))*g1;
Z=h*X;
e=z-Z;
disp('e=');
disp(e);
n=length(z);
m=length(X);
C=0;
for i=1:n
f=e(i)*e(i)*w(i,i);
C=C+f;
end
disp('f=');
disp(C);
k=n-m;
c=[ 3.84 5.02 6.64 7.88;
5.99 7.38 9.21 10.6
7.82 9.35 11.35 12.84];
disp(c)
for i=k
for j=3;
if C<c(k,3)
disp('accepted data')
elseif C>c(k,3)
disp('unaccepted data')
%identify bad data
h(4,:)=[];
z(4,:)=[];
w(4,:)=[];
w(:,4)=[];
end
end
end
end
% g=h'*w*h;
% g1=h'*w*z;
% X=inv(g)*g1;
% Z=h*X;
% e=z-Z;
% disp('e=');
% disp(e);
% C=0;
% for i=1:n
% fh(i)=((e(i)^2)*w(i,i));
% C=C+fh(i);
% end
% disp('f=');
% disp(fh(i));

You might also like