matlab function for amplitude
matlab function for amplitude
(OP)
Hi all,
I need some help finding a certain function (if it exists)
I have 2 vectors of experimental data (in sine form of amplitude vs frequency) and I need a function to calculate the average amplitude of my sine wave. I don't think curve fitting will work since the data is not very stable. The function needs to work directly with the experimental data.
Anyone know if this function exists and what it would be ?
Thanks
Ren
I need some help finding a certain function (if it exists)
I have 2 vectors of experimental data (in sine form of amplitude vs frequency) and I need a function to calculate the average amplitude of my sine wave. I don't think curve fitting will work since the data is not very stable. The function needs to work directly with the experimental data.
Anyone know if this function exists and what it would be ?
Thanks
Ren





RE: matlab function for amplitude
You say "in sine form of amplitude vs frequency". Do you mean you have a spectrum? Is it a power spectrum?
What precisely do you mean by the "average amplitude of my sine wave"? Do you mean the mean of your original signal? The rms of your original signal?
M
--
Dr Michael F Platten
RE: matlab function for amplitude
I have a response vs time graph for a given frequency and I want to get the amplitude of the response.
The signal is not steady for every cycle (the amplitude changes because it is experimental) so I want to find the average amplitude, (or average of the peaks and lows) not the mean or rms.
Is this clear?
Thanks,
Ren
RE: matlab function for amplitude
The discrete Hilbert transform suffers from the same drawbacks as the discrete Fourier transform in that both are affected by leakage so the results are not perfect. However in the example below it seems to work quite well.
CODE
% define a time vector
t = [0:0.01:9.99];
% our signal - a sine wave with a time varying amplitude
x = sin(4*pi*t); % the sine wave
envelope = 5+0.5*sin(pi*t); % the time varying amplitude
x_env = x.*envelope; % the complete signal
% add some random noise to make it look a bit
% more like measured data
signal = x_env + 0.2*rand(1,1000);
% find the hilbert transform of the measured signal
signal_h = hilbert(signal);
% square the hilbert transform and take the
% +ve square root to get the estimated envelope
envelope_est = sqrt(signal_h.*conj(signal_h));
% plot the original signal, the true envelope
% and the estimated envelope
plot(t,signal,t,envelope,t,envelope_est);
% find the mean of the true envelope
mean_true = mean(envelope)
% find the mean of the estimated envelope
mean_est = mean(envelope_est)
--
Dr Michael F Platten
RE: matlab function for amplitude
Cheers
Greg Locock
RE: matlab function for amplitude
I did think about Fourier but I wasn't sure on how to apply it. For Hilbert I could just measure the transform itself since it will represent the amplitude, right?
After further thinking, I'll just plot the signal and figure it out graphically since my analysis will have some significant error sources afterwards anyways.
Thanks for your help guys,
Ren