Broadband signal deesign
이전 댓글 표시
I'm looking to create a test broadband input signal but am having difficulties.
The signal I'm looking to create is a random phase 10-20Hz signal, Fs=10kHz. I've tried creating a power spectrum centered around the 10-20Hz range but cannot figure out how to correctly go back to the time domain from there.
Does anyone have any ideas on how to go about creating this type of signal?
Thanks, John
답변 (1개)
hello
maybe this
you can tune the frequency range , frequency spacing and amplitudes distribution according to your preferences
Fs 10 kHz is quite overkill for such low freq signal
Fs = 1e4;
dt = 1/Fs;
duration = 10; % seconds
t = (0:dt:duration)'; % time vector
freqs = (10:0.5:20); % 21 freqs with 0.5 Hz spacing
amplitudes = ones(size(freqs)); % flat or arbitrary spectral amplitude (up to you)
%% main loop
y = 0;
for ci = 1:numel(freqs)
y = y + amplitudes(ci)*sin(2*pi*freqs(ci)*t+rand*2*pi); % random phase sine
end
% FFT plot
[f1,fft_spectrum1] = do_fft(t,y);
figure(1)
plot(f1,fft_spectrum1,'-*')
xlim([0 50]);
title('FFT Sectrum')
ylabel('|X(f)|')
xlabel('Frequency[hz]')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [freq_vector,fft_spectrum] = do_fft(time,data)
time = time(:);
data = data(:);
dt = mean(diff(time));
Fs = 1/dt;
nfft = length(data); % maximise freq resolution => nfft equals signal length
%% use windowing or not at your conveniance
% no window
fft_spectrum = abs(fft(data))*2/nfft;
% % hanning window
% window = hanning(nfft);
% window = window(:);
% fft_spectrum = abs(fft(data.*window))*4/nfft;
% one sidded fft spectrum % Select first half
if rem(nfft,2) % nfft odd
select = (1:(nfft+1)/2)';
else
select = (1:nfft/2+1)';
end
fft_spectrum = fft_spectrum(select,:);
freq_vector = (select - 1)*Fs/nfft;
end
이 질문은 마감되었습니다.
카테고리
도움말 센터 및 File Exchange에서 Spectral Estimation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
