how to inverse signal in matlab ?
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hello in my exmaple i have this 2 signals : x=[3 11 7 0 -1 4 2] n1=-3:1:3 h=[ 2 3 0 -5 2 1] n2=-1:1:4
and i need to plot this plots : x(k)&h(k),x(k)&h(-k),x(k)&h(-1-k),x(k)&h(2-k) hoe ever so far i did only the first one :
x=[3 11 7 0 -1 4 2]
n1=-3:1:3
h=[ 2 3 0 -5 2 1]
n2=-1:1:4
subplot(2,2,1)
stem(n1,x)
hold on
stem(n2,h,':')
title('x(k) & h(k)');
xlim([-5 5])
xlabel('k')
legend('solid-x','dashed-h');
subplot(2,2,2)
stem(n1,x)
hold on
stem(n2,flip(h),':')
title('x(k) & h(-k)');
xlim([-5 5])
xlabel('k')
legend('solid-x','dashed-h');
how ever the my second plot is wrong . how to inverse my h(k) ? and moving it by 2 ? should run a for loop that will move my signal ?
0 commentaires
Réponses (1)
Ankita Bansal
le 26 Juin 2018
Hi, for h(-k) you need to change the sign of n2 and you need to flip it also.
Change " stem(n2,flip(h),':') " to:
% for h(-k)
stem(flip(-n2),flip(h),':')
% for h(-1-k)
stem(-1+flip(-n2),flip(h),':')
% for h(2-k)
stem(2+flip(-n2),flip(h),':')
Voir également
Catégories
En savoir plus sur Simulation, Tuning, and Visualization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!