semestralka

This commit is contained in:
Filipriec
2025-11-13 21:45:30 +01:00
parent 4f4b634dc8
commit 1efa2dbec6
3 changed files with 54 additions and 12 deletions

View File

@@ -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