semestralka

This commit is contained in:
Filipriec
2025-11-06 14:59:22 +01:00
parent e46f0d4336
commit ac80e6fd55
7 changed files with 144 additions and 1 deletions

View File

@@ -6,4 +6,3 @@ x = [8,8,8,8,8,8,8,8]
X = DFT_priama(x)
x = DFT_spatna(X)

32
hod3/1.m Normal file
View File

@@ -0,0 +1,32 @@
clc;
close all;
max_val = 99
n = 0:max_val
f = 0.05
% x = (x^5-x^3+x^2-1)*(x^6-2);
%
% Konvolucia
a = sin(2*pi*f*n)
b = sin(2*pi*f*n+0.5)
c = conv(a,b)
figure;
stem(a)
hold on;
stem(b)
figure;
stem(c)
figure;
% Korelacia
R = xcorr(a,b)
stem(R)
figure;
% AutoKorelacia
T = autocorr(a)
stem(T)

33
hod3/2.m Normal file
View File

@@ -0,0 +1,33 @@
clc;
close all;
max_val = 99
n = 0:max_val
f = 0.05
% x = (x^5-x^3+x^2-1)*(x^6-2);
%
% Konvolucia
a = sin(2*pi*f*n)
b = sin(2*pi*f*n+0.5)
c = conv(a,b)
figure;
stem(a)
hold on;
stem(b)
figure;
stem(c)
figure;
% Korelacia
R = xcorr(a,b)
stem(R)
figure;
% AutoKorelacia
T = autocorr(a)
stem(T)

30
hod4/1.m Normal file
View File

@@ -0,0 +1,30 @@
% y(n)=(3/4)*y(n-1) + (1/6)*y(n-2) + x(n)+(1/2)*x(n-1)
clc;
clear all;
close all;
cit = [1, 0.5]
men = [1, -0.75, -1/6]
roots(men)
figure;
zplane(cit, men)
figure;
freqz(cit, men, 'whole')
z = roots(cit);
p = roots(men);
theta = pi/4;
r = 0.99;
new_zero_pair = [0;0];
new_pole_pair = [r*exp(1j*theta); r*exp(-1j*theta)];
filter_cit = poly(new_zero_pair)
filter_men = poly(new_pole_pair)
z_new = [z; new_zero_pair];
p_new = [p; new_pole_pair];
cit_new = poly(z_new)
men_new = poly(p_new)
figure;
zplane(cit_new, men_new)
figure;
freqz(cit_new, men_new, 'whole')

28
hod4/2.m Normal file
View File

@@ -0,0 +1,28 @@
% y(n)=(3/4)*y(n-1) + (1/6)*y(n-2) + x(n)+(1/2)*x(n-1)
clc;
clear all;
close all;
cit = [1, 0.5]
men = [1, -0.75, -1/6]
roots(men)
figure;
zplane(cit, men);
figure;
freqz(cit, men, 'whole');
x = [zeros(1, 10), 1, zeros(1, 100)]
y = zeros(size(x));
for n = 3:length(x)
y(n) = 0.75*y(n-1) + (1/6)*y(n-2) + x(n) + 0.5*x(n-1)
stem(0:length(x)-1, y, 'filled'); % plot discrete-time sequence
title(['System output up to sample n = ' num2str(n)]);
xlabel('n');
ylabel('y(n)');
ylim([-0.5 1.5]); % fixed axis for stability
grid on;
pause(0.25);
end

Binary file not shown.

21
semestralka/1.m Normal file
View File

@@ -0,0 +1,21 @@
clc;
close all;
clear all;
% semestralka
rawText = fileread('data6.dat');
nums = regexp(rawText, '[-+]?\d+', 'match');
data = int16(str2double(nums));
X = DFT_priama(double(data))
n = length(X)
freq = (0:n-1)/n
figure;
plot(double(data));
figure;
plot(freq, X)
figure;
plot(freq, abs(X))
figure;
plot(freq, angle(X))