Professional Documents
Culture Documents
Izvjestaj 1
Izvjestaj 1
5
clear all;
close all;
load dionice.mat
x = rate;
scatter(1:length(x),x);
%Sistem 1
p = zeros(1,length(x));
for i= 2:length(x)
p(i)=0.8*x(i-1)+0.2*x(i);
end
subplot(3,1,1);
scatter(1:length(x),x);
hold on
scatter(1:length(x),p,'x');
%sistem 2
p2 = zeros(1,length(x));
for i= 3:length(x)
p2(i)=(1/3)*(x(i)+x(i-1)+x(i-2));
end
subplot(3,1,2);
scatter(1:length(x),x);
hold on
scatter(1:length(x),p2,'x');
p3 = zeros(1,length(x));
for i= 4:length(x)
p3(i)=x(i)+(1/3)*(x(i)-x(i-3));
end
subplot(3,1,3);
scatter(1:length(x),x);
hold on
scatter(1:length(x),p3,'x');
Prednost ovog filtera je to sto filter izravnjava nagla nasumina odstupanja, tako da daje
generalniji trend. A nedostatak je to sto zbog oslanjanja na prole vrijednosti moe dati
neispravne vrijednosti, tj. zakanjele, ako se trend pone naglo konzistentno mijenjati.
2.6
clear all
close all
n=1:10;
A=3; % 4 5 16
x=A*stepfun(n,0);
y=zeros(1,length(x));
y(1)=0.5;
for i=2:length(x)
y(i)=(1/2)*(y(i-1)+x(i)/y(i-1))
end;
stem(n,y);
A=3
A=4
A=5
A=16
2.7
clear all
close all
clc
%Koeficijenti za sistem S1
a1 = [1 -1/2];
b1 = [1];
%Koeficijenti za sistemi S2
a2 = [1];
b2 = [1/2 -6];
%Ulazni Delta impuls
x =[1 zeros(1,31)];
%Odziv sistema S1 na delta impuls
y1 = filter(a1,b1,x);
%Odziv sistema S2 na S1(x)
y2 = filter(a2,b2,y1);
figure;
subplot(2,1,1)
stem(y1)
subplot(2,1,2)
stem(y2,'r')
%Odziv sistema S2 na delta impuls
y3=filter(a2,b2,x);
%Odziv sistema S1 na S2(x)
y4=filter(a2,b2,y2);
figure;
subplot(2,1,1)
stem(y3)
subplot(2,1,2)
stem(y4,'r')
2.8
a)
clear all
close all
clc
n=-5:5;
% provjera linearnosti
x1=stepfun(n,0);
x2=stepfun(n,2);
a=2;
b=3;
y1=3*x1+1;
y2=3*x2+1;
y3=a*y1+b*y2;
y4=3*(a*x1+b*x2)+1;
subplot(3,1,1)
stem(n,y3)
hold on
stem(n,y4,'--r')
% provjera vremenske invarijantnosti
x1=stepfun(n,2);
y1=3*x1+1;
x2=stepfun(n,0);
y2=3*x2+1;
y2=[ 1 1 y2(1:end-2)];
subplot(3,1,2)
stem(n,y1)
hold on
stem(n,y2,'--r')
% provjera stabilnosti na dva ogranicena signala
x1=stepfun(n,2);
y1=3*x1+1;
x2=n.*(stepfun(n,-3)-stepfun(n,3));
y2=3*x2+1;
subplot(3,1,3)
stem(n,y1)
hold on
stem(n,y2,'--r')
b)
clear all
close all
clc
n=-5:5;
% provjera linearnosti
x1=stepfun(n,0);
x2=stepfun(n,2);
A=2;
a=2;
b=3;
y1=A*(1+0.2*x1).*cos(20*pi*n);
y2=A*(1+0.2*x2).*cos(20*pi*n);
y3=a*y1+b*y2;
y4=3*(a*x1+b*x2)+1;
subplot(3,1,1)
stem(n,y3)
hold on
stem(n,y4,'--r')
title('linearnost');
% provjera vremenske invarijantnosti
x1=stepfun(n,2);
y1=A*(1+0.2*x1).*cos(20*pi*n);
x2=stepfun(n,0);
y2=A*(1+0.2*x2).*cos(20*pi*n);
y2=[ 1 1 y2(1:end-2)];
subplot(3,1,2)
stem(n,y1)
hold on
stem(n,y2,'--r')
title('invarijantnost');
% provjera stabilnosti na dva ogranicena signala
x1=stepfun(n,2);
y1=A*(1+0.2*x1).*cos(20*pi*n);
x2=n.*(stepfun(n,-3)-stepfun(n,3));
y2=A*(1+0.2*x2).*cos(20*pi*n);
subplot(3,1,3)
stem(n,y1)
hold on
stem(n,y2,'--r')
title('stabilnost');
c)
clear all
close all
clc
n=-5:5;
% provjera linearnosti
x1=stepfun(n,0);
x2=stepfun(n,2);
a=2;
b=3;
y1=sinh(x1);
y2=sinh(x2);
y3=a*y1+b*y2;
y4=3*(a*x1+b*x2)+1;
subplot(3,1,1)
stem(n,y3)
hold on
stem(n,y4,'--r')
title('linearnost');
d)
clear all
close all
clc
n=-5:5;
% provjera linearnosti
x1=stepfun(n,0);
x2=stepfun(n,2);
a=2;
b=3;
y1=round(x1);
y2=round(x2);
y3=a*y1+b*y2;
y4=3*(a*x1+b*x2)+1;
subplot(3,1,1)
stem(n,y3)
hold on
stem(n,y4,'--r')
title('linearnost');
% provjera vremenske invarijantnosti
x1=stepfun(n,2);
y1=round(x1);
x2=stepfun(n,0);
y2=round(x2);
y2=[ 1 1 y2(1:end-2)];
subplot(3,1,2)
stem(n,y1)
hold on
stem(n,y2,'--r')
title('invarijantnost');
% provjera stabilnosti na dva ogranicena signala
x1=stepfun(n,2);
y1=round(x1);
x2=n.*(stepfun(n,-3)-stepfun(n,3));
y2=round(x2);
subplot(3,1,3)
stem(n,y1)
hold on
stem(n,y2,'--r')
title('stabilnost');