필터 지우기
필터 지우기

how to sum unit function and step function

조회 수: 4 (최근 30일)
chae hyeon shin
chae hyeon shin 2020년 5월 1일
답변: VIVEK 2022년 9월 20일
I want to calculate the convolution of x(t) and h(t).
Here is my code :
clear;
t = [ -10 : 0.01 : 10 ];
xt = ( t >= -2 ) & ( t <= 2) + (t == 1)
ht = ( t >= -1 ) & ( t <= 2) + 2*(t == 0) + (t == 3)
plot(t,ht);
ylim([-0.5 2]);
yt = conv(xt,ht,'same');
t1 = [-inf, inf];
plot(t1,yt);
I'm not sure that xt and ht are correct.
Moreover, there is an error with last line.
HELP ME
  댓글 수: 1
Ameer Hamza
Ameer Hamza 2020년 5월 1일
What does the upward arrow represent?

댓글을 달려면 로그인하십시오.

답변 (2개)

Ajay Pattassery
Ajay Pattassery 2020년 5월 4일
I assume you are trying to do the convolution of xt, ht as attached in the image.
t = ( -10 : 0.01 : 10 );
xt = (( t >= -2 ) & ( t <= 2)) + (t == 1);
ht = (( t >= -1 ) & ( t <= 2)) + 2*(t == 0) + (t == 3);
subplot(3,1,1);plot(t,xt);
ylabel('xt');
subplot(3,1,2);plot(t,ht)
ylabel('ht');
yt = .01*conv(xt,ht,'same');
subplot(3,1,3);plot(t,yt);
ylabel('yt');
I have just edited your above code.
If you are doing convolution of continuous signals by approximating as above in MATLAB, you need to multiply the output of conv with dt. In your case .01. What you are basically doing is approximating the continuous signal with boxes of width .01 and doing the discrete convolution. Hence while doing convolution, the integration can be achieved by mulitplying with dt.

VIVEK
VIVEK 2022년 9월 20일
t = ( -10 : 0.01 : 10 );
xt = (( t >= -2 ) & ( t <= 2)) + (t == 1);
ht = (( t >= -1 ) & ( t <= 2)) + 2*(t == 0) + (t == 3);
subplot(3,1,1);plot(t,xt);
ylabel('xt');
subplot(3,1,2);plot(t,ht)
ylabel('ht');
yt = .01*conv(xt,ht,'same');
subplot(3,1,3);plot(t,yt);
ylabel('yt');

카테고리

Help CenterFile Exchange에서 Waveform Generation에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by