How to create a low-frequency version of a signal in Matlab?

With a sinusoidal input, I tried to change its frequency by cutting off some lower frequencies in the spectrum, moving the main frequency to zero. Since the signal is not fftshifted, I tried to do this by excluding some patterns at the beginning and end of the fft vector:

interval = 1;
samplingFrequency = 44100;
signalFrequency = 440;
sampleDuration = 1 / samplingFrequency;
timespan = 1 : sampleDuration : (1 + interval);
original = sin(2 * pi * signalFrequency * timespan);
fourierTransform = fft(original);
frequencyCut = 10; %% Hertz
frequencyCut = floor(frequencyCut * (length(pattern) / samplingFrequency) / 4); %% Samples
maxFrequency = length(fourierTransform) - (2 * frequencyCut);
signal = ifft(fourierTransform(frequencyCut + 1:maxFrequency), 'symmetric');

But this did not work as expected. I also tried to remove the center of the spectrum, but he also used a high-frequency sine wave.

How to do it right?

+3
source share
2 answers

@ las3rjock:

, FFT. downsample.

timeseries resample.

EDIT:

:)

% generate a signal
Fs = 200;
f = 5;
t = 0:1/Fs:1-1/Fs;
y = sin(2*pi * f * t) + sin(2*pi * 2*f * t) + 0.3*randn(size(t));

% downsample
n = 2;
yy = downsample([t' y'], n);

% plot
subplot(211), plot(t,y), axis([0 1 -2 2])
subplot(212), plot(yy(:,1), yy(:,2)), axis([0 1 -2 2])

screenshot

+2

n

% downsample by a factor of 2
n = 2; % downsampling factor
newSpectrum = fourierTransform(1:n:end);

, , , . fftshift:

pad = length(fourierTransform);
fourierTransform = [zeros(1,pad/4) fftshift(newSpectrum) zeros(1,pad/4)];

, fftshift:

signal = ifft(fftshift(fourierTransform));

EDIT. script, , :

% generate original signal
interval = 1;
samplingFrequency = 44100;
signalFrequency = 440;
sampleDuration = 1 / samplingFrequency;
timespan = 1 : sampleDuration : (1 + interval);
original = sin(2 * pi * signalFrequency * timespan);

% plot original signal
subplot(211)
plot(timespan(1:1000),original(1:1000))
title('Original signal')

fourierTransform = fft(original)/length(original);

% downsample spectrum by a factor of 2
n = 2; % downsampling factor
newSpectrum = fourierTransform(1:n:end);

% zero-pad the positive and negative ends of the spectrum
pad = floor(length(fourierTransform)/4);
fourierTransform = [zeros(1,pad) fftshift(newSpectrum) zeros(1,pad)];

% inverse transform
signal = ifft(length(original)*fftshift(fourierTransform),'symmetric');

% plot the downshifted signal
subplot(212)
plot(timespan(1:1000),signal(1:1000))
title('Shifted signal')

http://img5.imageshack.us/img5/5426/downshift.png

+2

Source: https://habr.com/ru/post/1718562/


All Articles