Example of Multiple Operation on Discrete Signal | MATLAB

preview_player
Показать описание
Code is given in the comment section.

Prerequisite:-
Time delay and time advance of a sequence in MATLAB
Signal addition in MATALB
Рекомендации по теме
Комментарии
Автор

Code:-


n=-2:10;
x=[1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1];
n1=n+5;
n2=n-4;
y=3*x;
x=2*x;
u=min(min(n1), min(n2));
t=max(max(n1), max(n2));
r=u:1:t;
z1=[];
temp=1;
for i=1:length(r)
if(r(i)<min(n1) || r(i)>max(n1))
z1=[z1 0];
else
z1=[z1 x(temp)];
temp=temp+1;
end
end
z2=[];
temp=1;
for i=1:length(r)
if(r(i)<min(n2) || r(i)>max(n2))
z2=[z2 0];
else
z2=[z2 y(temp)];
temp=temp+1;
end
end
z=z1-z2;
stem(r, z);

KnowledgeAmplifier