Amplitude of a signal

10 Ansichten (letzte 30 Tage)
Zahra
Zahra am 5 Apr. 2023
Kommentiert: Mathieu NOE am 28 Jun. 2023
I have the attached signal. How can I get the voltage amplitude of this graph ?
This is a zoomed in graph:

Antworten (1)

Mathieu NOE
Mathieu NOE am 5 Apr. 2023
hello
  • basically you want to plot the envelope of your data , there is a function for that :
envelope Envelope detector.
[YUPPER,YLOWER] = envelope(X) returns the upper and lower envelopes of
the input sequence, X, using the magnitude of its analytic signal.
it requires the Signal Processing Toolbox
  • you may want to remove first the spikes , so a bit of low pass filtering / smoothing is needed
you can do that with smoothdata
If you don't have the Signal Processing Toolbox, see the demo below :
t = 0:0.01:10;
x = exp(-(t-5).^2/2).*sin(2*pi*5*t);
% obtain the envelope data
%--------------------------------------------
y = abs(hilbert(x)); % option 1 with hilbert
[up,down] = envelope2(t,x,'linear'); % option 2 with envelope2 (see below)
plot(t,x,t,y,'k',t,up,'m',t,down,'c')
legend('signal','hilbert','envelope2 / upper env','envelope2 / lower env');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [up,down] = envelope2(x,y,interpMethod)
%ENVELOPE gets the data of upper and down envelope of the known input (x,y).
%
% Input parameters:
% x the abscissa of the given data
% y the ordinate of the given data
% interpMethod the interpolation method
%
% Output parameters:
% up the upper envelope, which has the same length as x.
% down the down envelope, which has the same length as x.
%
% See also DIFF INTERP1
% Designed by: Lei Wang, <WangLeiBox@hotmail.com>, 11-Mar-2003.
% Last Revision: 21-Mar-2003.
% Dept. Mechanical & Aerospace Engineering, NC State University.
% $Revision: 1.1 $ $Date: 3/21/2003 10:33 AM $
if length(x) ~= length(y)
error('Two input data should have the same length.');
end
if (nargin < 2)|(nargin > 3),
error('Please see help for INPUT DATA.');
elseif (nargin == 2)
interpMethod = 'linear';
end
% Find the extreme maxim values
% and the corresponding indexes
%----------------------------------------------------
extrMaxIndex = find(diff(sign(diff(y)))==-2)+1;
extrMaxValue = y(extrMaxIndex);
% Find the extreme minim values
% and the corresponding indexes
%----------------------------------------------------
extrMinIndex = find(diff(sign(diff(y)))==+2)+1;
extrMinValue = y(extrMinIndex);
up = extrMaxValue;
up_x = x(extrMaxIndex);
down = extrMinValue;
down_x = x(extrMinIndex);
% Interpolation of the upper/down envelope data
%----------------------------------------------------
up = interp1(up_x,up,x,interpMethod);
down = interp1(down_x,down,x,interpMethod);
end
  1 Kommentar
Mathieu NOE
Mathieu NOE am 28 Jun. 2023
Hello
Problem solved ?
would you mind accepting my answer ? thanks !

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by