Professional Documents
Culture Documents
Projekt Iz Signala I Sustava: Student: Damir Dizdarević
Projekt Iz Signala I Sustava: Student: Damir Dizdarević
Kod:
hold off; clear;
x1=[2 2 2 0 0 0];
x2=[0 0 1 1 1 1];
n=-3:2;
subplot(4, 1, 1);
stem(n, x1);
title("x1[n]");
xlabel("n");
ylabel("x1[n]");
subplot(4, 1, 2);
stem(n, x2);
title("x2[n]");
xlabel("n");
ylabel("X2[n]");
nconv = (-6:4);
x12=conv(x1,x2);
subplot(4, 1, 3);
stem(nconv, x12);
title("x1[n] * x2[n]");
xlabel("n");
ylabel("x1[n] * x2[n]");
x21=conv(x2,x1);
subplot(4, 1, 4);
stem(nconv, x21);
title("x2[n] * x1[n]");
xlabel("n");
ylabel("x2[n] * x1[n]");
Zadatak 2.
Kod:
t = 0:Tconti:6/B;
t_n = 0:Tsample:6/B;
r = zeros(1,length(t));
sincovi = zeros(length(t_n), length(t));
x = cos(2*pi*B*t);
x_n = cos(2*pi*B*t_n);
for n=1:length(t_n)
for j=1:length(t)
sincovi(n,j) = sinc(2 * B * t(j) - (n - 1))*x_n(n);
end
end
for i=1:length(t)
for n=1:length(x_n)
r(i)=r(i) + sinc(2 * B * t(i) - (n - 1))*x_n(n); ;
end
end
% Originalni signal
subplot(4, 1, 1);
plot(t, x);
title("x(t)");
xlabel("t");
ylabel("x(t)");
% Uzorci
subplot(4, 1, 2);
stem(t_n, x_n);
title('x(nT)');
xlabel("n");
ylabel("x(nT)");
% Rekonstruirani signal
subplot(4, 1, 3);
plot(t, r);
title("xr(t)");
xlabel("t");
ylabel("xr(t)");
% Sincovi
subplot(4, 1, 4);
for i=1:length(t_n)
plot(t, sincovi(i,:));
hold on
end
title('xrn(nT)');
xlabel("t");
ylabel("xrn(nT)");
Zadatak 3.
Kod:
t = 0:1e-6:4/f0;
f = (0:N_0-1) / (Tsample * N_0);
n = 0:(N_0-1);
sigma=3;
% FFT
X = fft(x);
Xn = fft(xn);
subplot(5, 1, 1);
stem(n, x);
title("x[n]");
xlabel("n");
ylabel("x[n]");
subplot(5, 1, 2);
stem(f-1/(2 * Tsample), fftshift(abs(X)));
title("Magnitudni spektar za x[n]");
xlabel("f[Hz]");
ylabel("|X(f)|");
subplot(5, 1, 3);
stem(f-1/(2*Tsample), fftshift(angle(X)));
title("Fazni spektar za x[n]");
xlabel("f[Hz]");
ylabel("<X(f)");
subplot(5, 1, 4);
stem(n, xn);
title("x[n] sa aditivnim Gaussovim sumom");
xlabel("n");
ylabel("x_n[n]");
subplot(5, 1, 5);
stem(f-1/(2 * Tsample),fftshift(abs(Xn)));
title("Magnitudni spektar za x[n] sa aditivnim Gaussovim sumom");
xlabel("f[Hz]");
ylabel("|X_n(f)|");