Mean Amplitude of the signal

102 views (last 30 days)
Karolina
Karolina on 23 Mar 2012
Commented: Tor Aarskog on 18 Jun 2020
Hi, My problem is to calculate mean amplitude of the signal and plot it on the graph with signal course. Below you can see my source code:
y % signal vector, where [3083 1]= size(y)
Fs=100;
L=length(y);
NFFT = 2^nextpow2(L);
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
n1=1/100; %1
m1=L/100; %end
[a b]=size(y);
nov=(m1-n1)/(a-1);
x=n1:nov:m1;
figure
subplot(2,1,1)
plot(f,2*abs(Y(1:NFFT/2+1)),color) % amplitude spectrum
subplot(2,1,2)
plot(x,y,'b') % course of the signal
Could you tell me how can I calculated mean amplitude based on this? Or maybe there exists another way to find it? When I used mean(abs(Y(1:NFFT/2+1))) and ploted it on the second subplot it was far away from signal...

Accepted Answer

Wayne King
Wayne King on 23 Mar 2012
Hi Karolina, No, it's proportional to the amplitude squared of the Fourier coefficients. You can get amplitude estimates like this:
t = 0:0.01:5-0.01;
x = cos(2*pi*4*t)+1/2*cos(2*pi*8*t)+randn(size(t));
xdft = fft(x);
xdft = (2/length(x))*xdft(1:length(x)/2+1);
Now, you have to be able to figure out that the 4-Hz component lives in DFT bin (21) and the 8-Hz component lives in DFT bin (41)
abs(xdft(21))
abs(xdft(41))
Give you the amplitude estimates for those frequencies.
abs(xdft(16:51))
Gives you the amplitude estimates for 3-10 Hz.
Note that the spacing between DFT bins ist Fs/N where Fs is the sampling frequency and N is the length of the signal.
  2 Comments
Aqeel Syed Shamsi
Aqeel Syed Shamsi on 29 Sep 2018
Hi Wayne, what if I want amplitude estimates for 7-13 Hz? Please reply, I shall be very thankful to you!
Tor Aarskog
Tor Aarskog on 18 Jun 2020
Hi, By doing this i would get a vecor of values. Are they mean amplitudes, of the frequency range, in the time step? What would these values correspond to ?

Sign in to comment.

More Answers (2)

Arun Aniyan
Arun Aniyan on 23 Mar 2012
Hi,
I am not sure why you should do fourier transform to get the mean amplitude of your signal . For the mean amplitude of the signal for your case you can simply use
mean_amplitude = mean(y); % Find mean amplitude
d=ones(1,length(y)).*mean_amplitude; % A dummy vector having values of the mean
plot(x,y); % Plot your signal
hold all;
plot(d);
This will give a plot with the signal , with a straight line over plotted along the signal. Or do you mean , the mean amplitude of the spectrum ?
Cheers
- Arun
  1 Comment
Karolina
Karolina on 23 Mar 2012
Hi, I would like to find average amplitude of the signal eg in the range 3 - 10 Hz?

Sign in to comment.


Wayne King
Wayne King on 23 Mar 2012
Hi Karolina, You can find the average power of the signal in the [3,10] Hz band. If you have the Signal Processing Toolbox.
Fs = 100;
t = 0:0.01:1-0.01;
x = cos(2*pi*4*t)+1/2*sin(2*pi*8*t)+randn(size(t));
psdest = psd(spectrum.periodogram,x,'Fs',100,'NFFT',length(x));
pwr = avgpower(psdest,[3,10]);
You can also easily obtain what percentage of the power is contained in that interval
pwrratio = 100*(pwr/avgpower(psdest,[0,50]));
  1 Comment
Karolina
Karolina on 23 Mar 2012
Hi Wayne, thank you very much, but is the power the same as the amplitude?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!