Clear Filters
Clear Filters

Averaging a process over a certain number of cycles

2 views (last 30 days)
Hey,
Essentially, this is a transmit receive system. I transmit a signal, an attenuated and time shifted copy acts as the 'reflected signal' and I immerse this reflected signal in white gaussian noise. I then perform a matched filter on the receive channel (reflected signal + noise) by cross correlating it with the transmitted signal. However, since the noise is generated differently every time I run the script, I would like to repeat this process over X cycles and then average. Below is the section of the code where I think it should be implemented. plsreflatt is the signal vector and it gets added to gaussian noise r to form the vector rplsnoise. It then gets cross correlated with the initial transmission. Any help on how to do this averaging would be greatly appreciated! Thank you!
att=0.05;
plsreflatt=(att*refl)';
noisepeak = 0.1;
stdev=noisepeak/3;
%Generation of white Gaussian noise
r = randn(size(taxes))*stdev;
rplsnoise = r + plsreflatt;
[Amp,Time] = xcorr(rplsnoise,transmission);
%Inequalities included to plot values only above 0
Amp = Amp(Time>=0);
TimeF = Time(Time>=0)/sample_freq;

Answers (1)

Anurag
Anurag on 25 Oct 2023
Hi Felipe,
I understand that you want to average the result of your process over some finite cycles, please refer to the modified code below for achieving the desired results:
% Define the number of cycles you want to average over
X = 100; % Replace with your desired number of cycles
% Initialize arrays to accumulate results
accumulated_Amp = zeros(1, length(Time));
num_cycles = 0;
% Repeat the process X times
for cycle = 1:X
att = 0.05;
plsreflatt = (att * refl)';
% Generate white Gaussian noise
r = randn(size(taxes)) * stdev;
rplsnoise = r + plsreflatt;
[Amp, Time] = xcorr(rplsnoise, transmission);
% Inequalities included to plot values only above 0
Amp = Amp(Time >= 0);
% Accumulate results
accumulated_Amp = accumulated_Amp + Amp;
num_cycles = num_cycles + 1;
end
% Calculate the average
average_Amp = accumulated_Amp / num_cycles;
% Now, you can work with the average_Amp for further analysis or plotting.
Hope this helped,
Regards,
Anurag

Tags

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!