Question
Please show the Matlab code for the following question. close all n_trials = 10; SNR = 0.5; %signal to noise ratio, SNR = signal average
Please show the Matlab code for the following question.
close all
n_trials = 10;
SNR = 0.5; %signal to noise ratio, SNR = signal average poweroise average power samples = 1000;
x = -3*pi:6*pi/(samples):3*pi-6*pi/(samples); y = sin(x); %true signal
FT_y = fft(y); P_signal = norm(FT_y); P_signal = P_signal*P_signal; %average signal power
y_ave = zeros(size(y));
for k=1:n_trials y_noisy = zeros(size(y)); y_noisy(1 : noise_freq : end - noise_freq + 1) = randn(samplesoise_freq,1); % y_noisy = (rand(samples,1)-0.5); FT_noise = fft(y_noisy); P_noise_sqrt = norm(FT_noise); % P_noise = P_noise*P_noise; y_noisy = y + y_noisy*sqrt(P_signal/SNR)/P_noise_sqrt; %instance of noisy measurement with SNR as specified y_ave = y_ave + y_noisy; end
y_ave = y_ave_trials;
figure subplot(2,2,1); plot(x,y);
subplot(2,2,2); plot(x,y_ave);
%[f,t,Ts] = time_scale_tesselation(samples,y);
subplot(2,2,3); plot(-samples/2:samples/2-1,fftshift(abs(FT_y)));
FT_y_ave = fft(y_ave); subplot(2,2,4); plot(-samples/2:samples/2-1,fftshift(abs(FT_y_ave))); P_noise_ave = norm(FT_y - FT_y_ave); P_noise_ave = P_noise_ave*P_noise_ave;
SNR_ave = P_signal/P_noise_ave
10. MATLAB 2: Find the attached script 'Homeworkl question10.m' This script simulates signal averaging of noisy signals noise over a sine wave, and averages the noisy measurement over n trials. White noise is random noise with uniform power spectrum for all frequencies. The original and averaged noisy signals are plotted along with their FT's. li generaios (lau ::;in whil 10. MATLAB 2: Find the attached script 'Homeworkl question10.m' This script simulates signal averaging of noisy signals noise over a sine wave, and averages the noisy measurement over n trials. White noise is random noise with uniform power spectrum for all frequencies. The original and averaged noisy signals are plotted along with their FT's. li generaios (lau ::;in whilStep 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