Add 2 sec. of noise as a reference for a spectrogram infront of a 2 second long sinus function.
이전 댓글 표시
Hey,
I want to test some spectrogram technics, so my plan was to use the standard C major scale as an example for.
So, I generate a sine function with the frequencies for the tones of the scale.
My question is how can i add a for example randome noise, or white noise or something as a reference nois for the sine wave infront of it. In the end i want to have a 4 sec. long signal, the first 2 sec. should be just reference noise folllowed by 2 secs. of sine wave.
Thats how i code the sine function:
clear all
clc
fs = 44200; % Sampling frequency (samples per second)
dt = 1/fs; % seconds per sample
StopTime = 2; % seconds
t = (0:dt:StopTime-dt)'; % seconds
F = 432; % Sine wave frequency (hertz)
data = sin(2*pi*F*t);
Thank you very much.
답변 (1개)
Try this —
fs = 44200; % Sampling frequency (samples per second)
dt = 1/fs; % seconds per sample
StopTime = 2; % seconds
noisev = randn(2*fs,1)*0.35; % Length = Samples/sec * sec (Column Vector)
t = (0:dt:StopTime-dt)'; % seconds
F = 432; % Sine wave frequency (hertz)
data = sin(2*pi*F*t);
data = [noisev; data]; % Concatenate
L = numel(data);
t_new = linspace(0, L-1, L)/fs; % Seconds
figure
plot(t_new, data)
grid
xlabel('Time (s)')
ylabel('Amplitude')
It might be appropriate to further scale the ‘noisev’ vector to avoid clipping and saturation.
.
카테고리
도움말 센터 및 File Exchange에서 Get Started with Signal Processing Toolbox에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
