已知离散时间信号f(k)=2[u(k)-u(k-2)],试用matlab绘出f(k),f(-k),-f(k),f(k-2).的时域波形。
syms k;
k=-5:5
f=sym('2*(heaviside(k)-heaviside(k-2))');
stem(k,f)
set(gcf,'color','w')
title('f(k)')
pause
f1=subs(f,k,-k);
stem(k,f1)
title('f(-k)')
pause
f2=-f;
stem(k,f2)
title('-f(k)')
pause
f3=subs(f,k,k-2);
stem(k,f3)
title('f(k-2)')
pause
这是我写的,可是有点错误,大家帮忙看下吧,弄好了我加分哦!
syms k;
k=-5:5
f11=sym('2*(heaviside(k)-heaviside(k-2))');
f1=subs(f11);
subplot(221)
stem(k,f1)
set(gcf,'color','w')
title('f(k)')
f2=sym('2*(heaviside(-k)-heaviside(-k-2))');
f2=subs(f2);
subplot(222)
stem(k,f2)
title('f(-k)')
f3=-f11;
f3=subs(f3);
subplot(223)
stem(k,f3)
title('-f(k)')
f4=sym('2*(heaviside(k-2)-heaviside(k-4))');
f4=subs(f4);
subplot(224)
stem(k,f4)
title('f(k-2)')