semestralka
This commit is contained in:
@@ -7,26 +7,37 @@ rawText = fileread('data6.dat');
|
||||
nums = regexp(rawText, '[-+]?\d+', 'match');
|
||||
data = int16(str2double(nums));
|
||||
|
||||
X = DFT_priama(double(data))
|
||||
n = length(X)
|
||||
X = DFT_priama(double(data));
|
||||
n = length(X);
|
||||
Fs = 200;
|
||||
freq = (0:n-1)*Fs/n
|
||||
freq = (0:n-1)*Fs/n;
|
||||
|
||||
figure;
|
||||
plot(double(data));
|
||||
figure;
|
||||
plot(freq, X)
|
||||
%3
|
||||
figure;
|
||||
x = double(data);
|
||||
x = x - mean(x);
|
||||
plot(x); % centrovane data
|
||||
magX = abs(X);
|
||||
plot(freq, magX)
|
||||
% freq shift pre -Fs/2 po Fs/2
|
||||
freq_shift = (-n/2:n/2-1)*(Fs/n);
|
||||
%4
|
||||
figure;
|
||||
plot(freq, abs(X))
|
||||
subplot(2,1,1);
|
||||
plot(freq_shift, real(fftshift(X)), 'b');
|
||||
subplot(2,1,2);
|
||||
plot(freq_shift, imag(fftshift(X)), 'r');
|
||||
%5
|
||||
figure;
|
||||
plot(freq, imag(X), 'r');
|
||||
%6
|
||||
figure;
|
||||
plot(freq, real(X), 'r');
|
||||
figure;
|
||||
plot(freq, angle(X))
|
||||
|
||||
magX = abs(X);
|
||||
[pks, locs] = findpeaks(magX, 'NPeaks', 6, 'SortStr', 'descend');
|
||||
|
||||
f0 = freq(locs);
|
||||
disp(f0);
|
||||
[pks, locs] = findpeaks(magX, 'NPeaks', 10, 'SortStr', 'descend');
|
||||
f0 = freq(locs)
|
||||
f0b = f0(f0 < 100);
|
||||
f0_ohranicene = f0b
|
||||
|
||||
29
semestralka/2.m
Normal file
29
semestralka/2.m
Normal file
@@ -0,0 +1,29 @@
|
||||
clc;
|
||||
close all;
|
||||
clear all;
|
||||
|
||||
f0_ohranicene = [25, 20, 10, 12.5];
|
||||
% semestralka
|
||||
rawText = fileread('data6.dat');
|
||||
nums = regexp(rawText, '[-+]?\d+', 'match');
|
||||
data = int16(str2double(nums));
|
||||
|
||||
Fs = 200;
|
||||
r = 0.95;
|
||||
b = 1;
|
||||
a = 1;
|
||||
|
||||
for k = 1:length(f0_ohranicene)
|
||||
theta = 2*pi*(f0_ohranicene(k)/Fs);
|
||||
b = conv(b, [1, -2*cos(theta), 1]);
|
||||
a = conv(a, [1, -2*r*cos(theta), r^2]);
|
||||
end
|
||||
|
||||
figure;
|
||||
zplane(b, a);
|
||||
figure;
|
||||
freqz(b, a);
|
||||
figure;
|
||||
freqz(b, a);
|
||||
filtered_data = filter(b, a, double(data));
|
||||
plot(filtered_data);
|
||||
2
semestralka/docs.txt
Normal file
2
semestralka/docs.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
https://en.wikipedia.org/wiki/Infinite_impulse_response
|
||||
https://courses.physics.illinois.edu/ece401/fa2020/slides/lec15.pdf
|
||||
Reference in New Issue
Block a user