semestralka
This commit is contained in:
@@ -7,26 +7,37 @@ rawText = fileread('data6.dat');
|
|||||||
nums = regexp(rawText, '[-+]?\d+', 'match');
|
nums = regexp(rawText, '[-+]?\d+', 'match');
|
||||||
data = int16(str2double(nums));
|
data = int16(str2double(nums));
|
||||||
|
|
||||||
X = DFT_priama(double(data))
|
X = DFT_priama(double(data));
|
||||||
n = length(X)
|
n = length(X);
|
||||||
Fs = 200;
|
Fs = 200;
|
||||||
freq = (0:n-1)*Fs/n
|
freq = (0:n-1)*Fs/n;
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
plot(double(data));
|
plot(double(data));
|
||||||
figure;
|
figure;
|
||||||
plot(freq, X)
|
plot(freq, X)
|
||||||
|
%3
|
||||||
figure;
|
figure;
|
||||||
x = double(data);
|
magX = abs(X);
|
||||||
x = x - mean(x);
|
plot(freq, magX)
|
||||||
plot(x); % centrovane data
|
% freq shift pre -Fs/2 po Fs/2
|
||||||
|
freq_shift = (-n/2:n/2-1)*(Fs/n);
|
||||||
|
%4
|
||||||
figure;
|
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;
|
figure;
|
||||||
plot(freq, angle(X))
|
plot(freq, angle(X))
|
||||||
|
|
||||||
magX = abs(X);
|
[pks, locs] = findpeaks(magX, 'NPeaks', 10, 'SortStr', 'descend');
|
||||||
[pks, locs] = findpeaks(magX, 'NPeaks', 6, 'SortStr', 'descend');
|
f0 = freq(locs)
|
||||||
|
f0b = f0(f0 < 100);
|
||||||
f0 = freq(locs);
|
f0_ohranicene = f0b
|
||||||
disp(f0);
|
|
||||||
|
|||||||
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