convolution of two unit step functions.
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
justin stephens
le 19 Fév 2018
Réponse apportée : justin stephens
le 20 Fév 2018
alright folks, the issue i am having is that i am trying to use convolution on two step functions but for one i have an odd interval that i cannot figure out how to program in matlab. Here is the set up: x[n]= 1 ; 0<=n<=9 otherwise 0, h[n]= 1; 0<=n<=N where N is <= 9 otherwise 0. my problem in i do not know how to express this extra boundary in matlab. here is the code i have written thus far.
code
end
nx=-1:9;
N<=9;
nh=0:N;
x=usD(n);
h=usD(n);
y=conv(x,h);
ny=(nx(1) + nh(1) + (0:length(nx) + length(nh) - 2));
plot (ny,y);
0 commentaires
Réponse acceptée
Shounak Shastri
le 20 Fév 2018
1. The first thing you need to know is that in Matlab, the array index starts from 1 and not from 0. So if you write x(0)=1, you would get an error.
So you need to modify your limits to x[n]= 1 ; 1<=n<=10 and N<=10.
2. The statement
N<=9;
will give you a true or false answer as it is a logical statement. Also, the answer would be of no use as it is not being stored or used as a flag in any way.
3. As for the boundary, you can simply add a if statement inside a for loop.
for ii=1:length(h)
if ii>=1 && ii<=N % considering you have added 1 as described in 1
h(ii)=1;
else
h(ii)=0;
end
end
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering 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!