MATLAB Answers

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

조회 수: 2(최근 30일)
Jordan Willis
Jordan Willis 2021년 1월 27일
댓글: Jordan Willis 2021년 2월 1일
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
Jordan Willis
Jordan Willis 2021년 2월 1일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Tarunbir Gambhir
Tarunbir Gambhir 2021년 1월 29일
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.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by