Question
using the file sig_noise from below create a matlab file that has a signal with one distinct frequency and a signal-to-noise of 5 db. Use
using the file sig_noise from below create a matlab file that has a signal with one distinct frequency and a signal-to-noise of 5 db. Use data rate of 10 kHz and time period of 2 seconds.
a) plot the signal
b) show that this signal does in fact have two different distinct frequencies.
c) demonstrate that the signal does have a signal-to-noise of 5 db.
d) repeat a-c but with 35 distinct frequencies and a signal to noise of -2 db
sig_noise
fs = 1000; % Assume a sampling freq of 1 kHz Ts = 1/fs; time = (0:(N-1))*Ts; noise = randn(1,N); % Generate noise and calculate RMS value rms_noise = sqrt(mean(noise.^2)); if length(snr) < length(freqsin) && length(snr) == 1 % Check SNR vector length snr(2:length(freqsin)) = snr(1); %If a scalor, use this value for all freq. elseif length(snr) < length(freqsin) disp('Error: not enough SNR values') waveform_noise = rms_noise; return end % for i = 1:length(freqsin) freq_scale = freqsin(i) * 2 * pi/fs; x = (1:N) * freq_scale; snr_n = 10^(snr(i)/20); % Convert from dB A = snr_n * rms_noise * 1.414; % Determine gain for appropriate SNR if i == 1 component = sin(x) * A; waveform = component; rms_sig(i) = sqrt(mean(waveform.^2)); else component = sin(x) * A; rms_sig(i) = sqrt(mean(component.^2)); waveform = waveform + component; end snr_out(i) = 20 * log10(rms_sig(i)/rms_noise); % Confirm SNR end waveform_noise = waveform + noise;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started