How to compute the mean amplitude of each frequency across trials?
8 次查看(过去 30 天)
显示 更早的评论
This is probably so easy but I can't get it. After doing a fourier transform (the data matrix is trials x time so I think I do a fft in the column dimension), I first compute (for each trial) the amplitude of each frequency based on the Fourier transformed data, what I've done so far is below. It gives me a 1x450 vector.
Data=fft(data,[],2);
Dataamp = abs(Data)/n;
Dataamp = 2*Dataamp(1:n_cutoff); % scales the amps and cuts off at Nyquist
Dataamp(1) = Dataamp(1)/2; % not to scale the first term
But I now need to calculate (and later plot) the mean amplitude of each frequency across trials and would have thought I need to get the mean across each row, as in a column vector, but besides using the mean function (which only gives a single value as Dataamp is now a vector and I need multiple values) I don't know how else to think about it / go about it? i.e. what am I doing wrong?
0 个评论
采纳的回答
David Goodmanson
2018-3-21
Hi Becky,
I assume you have trials changing down, time changing across (each row is a trial as a function of time). The first two lines are good, but on then since you want to still preserve the rows, take a look at
Dataamp = 2*Dataamp(:,1:n_cutoff) % scales the amps and cuts off at Nyquist
Dataamp(:,1) = Dataamp(:,1)/2; % not to scale the first term
Meanamp = mean(Dataamp);
which produces a row vector of mean(abs(amplitude)).
If n is odd this is all right but if n is even I don't believe you want to double the nyquist term, so you should test for n even and if so then do
Dataamp(:,n_cutoff) = Dataamp(:,n_cutoff)/2; % not nyquist either
3 个评论
David Goodmanson
2018-3-22
Hi Becky,
I'm assuming as before that you have trials changing down, time changing across. So a matrix that is, say, 100 x 400 has 100 trials, each trial being a row vector with 400 samples in time,is that correct? If so, a picture being worth 2^10 words:
time --->
tri- d d d d d d d d
als d d d d d d d d
| d d d d d d d d
| d d d d d d d d
\/ d d d d d d d d
When you take the fft along the rows as you did, you get
frequency --->
tri- d d d d d d d d
als d d d d d d d d
| d d d d d d d d
| d d d d d d d d
\/ d d d d d d d d
Then to get the mean at each frequency you take the mean down the columns to get
frequency --->
mean over trials d d d d d d d d
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!