echo on d = 3; alpha = 10; t=(0:0.1:1).'; if ~exist('x'), x = sin(2*pi*t)+0.2*randn(size(t)); end tt=(-0.2:0.01:1.2).'; yy = sin(2*pi*tt); % tt = t; [p,S] = polyfit(t,x,d); [y1,E1]=polyconf(p,tt,S,0.01*alpha); % PRIMA METODA STANDARDNI POLYNOMIALNI REGRESE [y2,E,r,s] = polyfilt(d,length(t),x,t,tt,alpha,gcf); E2 = E(:,2); s hold on; plot(tt,yy,'r'); hold off; max(abs(y1-y2)), max(abs(E1-E2)) % ans = % 1.3767e-014 % ans = % 3.5527e-015 pause; % NEPRIMA METODA STANDARDNI POLYNOMIALNI REGRESE [R,E0] = polyfilt(d,length(t),[],t,tt,alpha); y2 = R*x; E0=s*E0; E2 = E0(:,2); max(abs(y1-y2)), max(abs(E1-E2)), max(abs(E-E0)) % KONTROLNI VYPOCET SIGMA s: y = polyfilt(d,length(t),x,t,[],alpha,figure); hold on; plot(tt,yy,'r'); hold off; s = norm(y-x)./sqrt(length(t)-d-1) [yy,EE] = polyfilt(d,length(t),x,t,[],alpha); max(abs(y-yy)), max(abs(E0(21:10:length(tt)-19,:)-EE)) ax = axis; figure(gcf-1); axis(ax); pause; % POSTUPNA POLYNOMIALNI REGRESE figure; for k = 1:4 subplot(2,2,k); polyfilt(d,length(t)-k,x,t,tt,alpha,gcf); axis(ax); end echo off