How to build a for-loop for 3rd dimensional noise realizations

2 views (last 30 days)
I am currently working on some research and was given a signal set of 1000x320x10 that I need to filter. The 3rd dimension is the number of noise realizations present. For a prior signal set, I used a for-loop to cycle through the data, line-by-line, and save the newly filtered data for later testing. I now need to include a seperate for-loop to also go through the 10 noise realization, but I am unsure how to properly make it go through the consecutive loops of that 3rd dimension. Do i just nest another for loop in there somewhere after filtering the original 1000 rows? Or do I need to filter them each row by row (1x320x1, 1x320x2, 1x320x3,...,1x320x10)?
Thank you!
clc;
clear;
close all;
load Wifi_Data_9dB_L5;
Fs = 20e6; %Establishing Variables
Fsamp = 20e6;
BW = 7.7e6;
Rp = 0.01;
Order = 4;
ImpPlot = 0;
PrntPlots = 0;
Rp = 0.01;
%%--------------------------------------------------------------------------
Tsamp = 1/Fsamp; %Filter variables
SNR = 9;
NumMC = 10;
FiltType ='Cheby';
N = 6;
for i = 1:1000
New_Sig = SigPlusNoise(i,:); %Drawing signal from given matrix
SigIn = New_Sig; %Establihing input signal
cheby = LPF_ChebyI_V1(SigIn,Fsamp,Order,BW,Rp,ImpPlot,PrntPlots); %Filter function
New_data(i,:) = (cheby); %Making new matrix
end
save('New_data') %Saving filtered signal in file New_Data
  1 Comment
Jordan Willis
Jordan Willis on 1 Feb 2021
For anybody that reads this in the future, the issue is that I was being given a cell with a huge matrix crammed into it. So, using Tarunbir's answer, all I had to change was to use SigPlusNoise{1} in combination with the (i, :, j).
My code is now listed below and runs fine.
for i = 1:1000
for j = 1:10
New_Sig = SigPlusNoise{1}(i,:,j); %Drawing signal from given matrix
SigIn = New_Sig; %Establihing input signal
cheby = LPF_ChebyI_V1(SigIn,Fsamp,Order,BW,Rp,ImpPlot,PrntPlots); %Filter function
New_data(i,:,j) = (cheby); %Making new matrix
end
end

Sign in to comment.

Accepted Answer

Tarunbir Gambhir
Tarunbir Gambhir on 29 Jan 2021
Based on the information you have shared, I assume that you have 1000 samples of signals which are of length 320, and have 10 different noise realizations each.
I suggest you use a nested for loop to go through the third dimension, filtering among different noise levels for each signal. Something like this should work.
for i = 1:1000
for j = 1:10
New_Sig = SigPlusNoise(i,:,j); %Drawing signal from given matrix
SigIn = New_Sig; %Establihing input signal
cheby = LPF_ChebyI_V1(SigIn,Fsamp,Order,BW,Rp,ImpPlot,PrntPlots); %Filter function
New_data(i,:,j) = (cheby); %Making new matrix
end
end
On a side note, I advise you to initialise 'New_data' variable with the correct size before entering the for loop.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!