Inputting signal at teager energy equation
7 次查看(过去 30 天)
显示 更早的评论
Question:
4. Here we use Teager’s energy tracker instead. For an input signal 𝑠(𝑘) sampled at 𝑡 = 𝑘𝑇s, Teager’s tracker computes
𝑇(𝑘) = 𝑠(𝑘)^2 − 𝑠(𝑘 + 1)𝑠(𝑘 − 1).
Plot 𝑇0(𝑘), which is 𝑇(𝑘) when 𝑠(𝑘) = ANS, and 𝑇1(𝑘), which is when 𝑠(𝑘) = ANSam. Also plottheir Fourier transforms. Confirm that 𝑇0(𝑘) is a d.c. signal and 𝑇1(𝑘) is a d.c. plus a tone. What is the frequency of the tone?
Code:
function [ey,ex]=energyop(sig,gr)
%% %calculates the energy operator of a signal
%% %input
1. Raw signal (Vector)
2. gr (Plot or not plot)
%% %Output
Energy operator signal (ey)
Teager operator (ex)
%%
if nargin<2
gr=0;
end
sig=sig(:);
%% (x(t)) = (dx/dt)^2+ x(t)(d^2x/dt^2)
%Operator 1
y=diff(sig);
y=[0;y];
squ=y(2:length(y)-1).^2;
oddi=y(1:length(y)-2);
eveni=y(3:length(y));
ey=squ - (oddi.*eveni);
%% [x[n]] = x^2[n] - x[n - 1]x[n + 1]
%operator ex
squ1=sig(2:length(sig)-1).^2;
oddi1=sig(1:length(sig)-2);
eveni1=sig(3:length(sig));
ex=squ1 - (oddi1.*eveni1);
ex = [ex(1); ex; ex(length(sig)-2)]; %make it the same length
%% plots
if gr
figure,ax(1)=subplot(211);plot((sig/max(sig))-mean(sig/max(sig)),'b'),
hold on,
plot((ey/max(ey))-mean(ey/max(ey)),'Linewidth',2,'LineStyle','--','color','r'),
axis tight;
hleg1=legend('Original Signal','Energy Operator');
set(hleg1,'Location','NorthWest')
ax(2)=subplot(212);plot((sig/max(sig))-mean(sig/max(sig)),'b'),
hold on,
plot((ex/max(ex))-mean(ex/max(ex)),'Linewidth',2,'LineStyle','--','color','g'),
hleg2=legend('Original Signal','Teager Energy');
set(hleg2,'Location','NorthWest')
axis tight,
zoom on;
linkaxes(ax,'x');
end
How to input my signals here???
0 个评论
回答(1 个)
Sai Pavan
2024-1-24
Hello,
I understand that you want to know how to input a signal into the Teager energy function 'energyop'.
The 'energyop' function needs to be called with the input signal as the first argument 'sig'. The second argument 'gr' is optional and controls whether or not the function will plot the results. The results can be plotted by setting the 'gr' parameter to 1.
Please refer to the below code snippet illustrating the procedure to input a DC signal and an amplitude modulated signal into the 'energyop' function and plotting it by setting the second argument of the function to 1:
% Define signal parameters
A = 1; % Amplitude of the carrier signal
a = 1; % Amplitude of the message signal
N = 1000; % Number of samples
m = 1; % Frequency of the message signal in Hz
S = 5; % Carrier frequency of the signal in Hz
fs = 100; % Sampling frequency in Hz
t = (0:N-1)/fs; % Time vector
% Create the signals
s0 = A * ones(size(t)); % DC signal
s1 = A * (1 + a * cos(2 * pi * m * t)) .* cos(2 * pi * S * t); % Amplitude modulated signal
% Use energyop function
[ey0, ex0] = energyop(s0, 1); % For the DC signal
[ey1, ex1] = energyop(s1, 1); % For the amplitude modulated signal
Hope it helps!
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!