final code for css

This commit is contained in:
Priec
2025-12-02 22:55:37 +01:00
parent 1efa2dbec6
commit 9bf8347b79
5 changed files with 219 additions and 72 deletions

56
semestralka/IIR_SOS.m Normal file
View File

@@ -0,0 +1,56 @@
clc;
close all;
clear all;
f0_ohranicene = [25, 20, 10, 12.5];
rawText = fileread('data6.dat');
nums = regexp(rawText, '[-+]?\d+', 'match');
data = int16(str2double(nums));
Fs = 200;
r = 0.98;
% predalokovana SOS matica pre vsetky filtrovane zlozky
% 6 lebo koeficienty [b0, b1, b2, a0, a1, a2]
sos = zeros(length(f0_ohranicene), 6);
for k = 1:length(f0_ohranicene)
theta = 2 * pi * (f0_ohranicene(k) / Fs);
b = [1, -2*cos(theta), 1];
a = [1, -2*r*cos(theta), r^2];
sos(k, :) = [b, a]
end
figure;
[z, p, k_gain] = sos2zp(sos);
figure;
zplane(z, p);
title('Nuly a póly filtra');
xlabel('Reálna časť');
ylabel('Imaginárna časť');
set(gcf, 'Color', 'none');
set(gca, 'Color', 'none');
print('-depsc', 'fig2_semE.eps');
figure;
freqz(sos, 4096, Fs);
title('Frekvenčná charakteristika SOS filtra');
xlabel('Frekvencia [Hz]');
ylabel('Zosilnenie [dB]');
set(gcf, 'Color', 'none');
set(gca, 'Color', 'none');
print('-depsc', 'fig3_semE.eps');
filtered_data = sosfilt(sos, double(data));
figure;
plot(filtered_data);
title('Filtrovaný signál');
xlabel('Vzorky');
ylabel('Amplitúda');
grid on;
set(gcf, 'Color', 'none');
set(gca, 'Color', 'none');
set(gcf, 'PaperPosition', [0 0 1.7*6 0.75*4.2]);
set(gcf, 'PaperSize', [1.7*6 0.75*4.2]);
print('-depsc', 'fig4_semE.eps');