convolution of two unit step functions.

조회 수: 7 (최근 30일)
justin stephens
justin stephens 2018년 2월 19일
답변: justin stephens 2018년 2월 20일
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);

채택된 답변

Shounak Shastri
Shounak Shastri 2018년 2월 20일
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

추가 답변 (1개)

justin stephens
justin stephens 2018년 2월 20일
thank you!

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by