Averaging lots of columns at once and then combining them

3 ビュー (過去 30 日間)
Ryan Chhiba
Ryan Chhiba 2021 年 3 月 6 日
コメント済み: Ryan Chhiba 2021 年 3 月 7 日
I have 2 and a half minutes of EMG data that I need to conduct a short time fourier transform on and then average within the short 250 ms epochs. Then that data needs to be combined into 20 second intervals. I used the buffer funtion to separate the data into 250 ms intervals but I cannot figure out a way to take the average of each coloumn without manually inputing it. Is there a way to do it all at once as there are 24000 columns. And also how would I be able to combine the averaged data into 20sec intervals, I tried the buffer function but that didn't work. My code can be seen below.
Fs = 2048; % Sampling Frequency
segment = 0.25; % Segments (250 msec)
Samples_fft = round (Fs * segment); % Sample Length
L_UTR_int_fft = buffer(L_UTR_Detr, Samples_fft); %this will create columns that contain 20 sec of data
% 4) Complete the Fast Fourier Transform
Fs= 2048; % Sampling Frequency
L= length(L_UTR_Cond); % Signal Length
t= mean(diff((L_UTR_Cond)); %Sampling Time
Fn= Fs/2 % Nyquist Frequency
L_UTR_fft= fft(L_UTR_int_fft)
P2=abs(L_UTR_fft /L);
P1=P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
L_UTR_fft_final = fs*(0:(L1/2))/L1; % I saw this online, and I think it needs to be done

採用された回答

dpb
dpb 2021 年 3 月 6 日
"...I cannot figure out a way to take the average of each col[o]umn without manually inputing it. "
Fs = 2048; % Sampling Frequency
segment = 0.25; % Segments (250 msec)
Samples_fft = round (Fs * segment); % Sample Length
L_UTR_mean=mean(buffer(L_UTR_Detr, Samples_fft),2); % time-domain average of columns
...
For averaging PSD, fft will operate by column; simply then use MATLAB array operations to operate over each column as if it were a vector then average the result as above.
See documentation for all functions--virtually all have the optional dim input paramter to tell them which dimension you wish to operate over if not the default by column.
Some, like std are tricky in that the dim input isn't the second so you may need to use a placeholder to get the desired argument.
  5 件のコメント
dpb
dpb 2021 年 3 月 7 日
Same way as for 250 msec intervals???
Ryan Chhiba
Ryan Chhiba 2021 年 3 月 7 日
I understand, but in order for the data to be accurate, a short time fourier transform must be conducted first. This requires an FFT over small epochs (250ms) to help better identify trends. This is why they need to be broken into small epochs, After caluclating the medfreq, I tried to use the buffer function on the data again but it would not work.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by