How do i do this in MATLAB?
Show older comments
I've got 2 noise vectors(x1 and x2) that I need to add to the pwelch command but I can't figure out what's wrong with my code. How do I add the 2 vectors together for the pwelch command? please help. code is below
f1 = 4000; %sinusoidal frequency
A1 = 0.2; %amplitude
f2 = 5000; %sinusoidal frequency
A2 = 0.25; %amplitude
t1 = 0:1/f1:5-1/f1;
t2 = 0:1/f2:5-1/f2;
x1 = A1*cos(2*pi*f1*t)+randn(size(t1));
x2 = A2*cos(2*pi*f2*t)+randn(size(t2));
x = x1+x2;
[y,Fs]=audioread('doorbell.wav');
[pxx,f] = pwelch(x,500,300,500,Fs);
plot(f,10*log10(pxx)); xlabel('Frequency (Hz)'); ylabel('PSD (dB/Hz)');
Accepted Answer
More Answers (0)
Categories
Find more on Spectral Estimation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!