i want draw x(t) h(t) y(t) in just one plot window

조회 수: 2 (최근 30일)
rollcakes
rollcakes 2015년 10월 9일
댓글: Star Strider 2015년 10월 9일
i want draw x(t) h(t) y(t) in just one plot window
Ts=0.01;
t=[ -4 : Ts : 4 ];
x=3*rectpuls(t/2);
h=2*rectpuls(t/4);
y=Ts*conv(x,h);
ty=[0:length(y)-1]*Ts-6;
plot(t,x,'R');
hold on;
plot(t,h,'B');
hold on;
plot(ty,y,'G');
axis([-4 4 0 6]);
hold on;
But graph is incorrect
y(t) i think..
start -1~1 = start Increase
1~3 = maximum
3~4= Decrease
please help TT

채택된 답변

Star Strider
Star Strider 2015년 10월 9일
The problem is that you need to not change ‘t’ in the convolution plot. This looks correct to me:
y=Ts*conv(x,h,'same'); % Use The ‘same’ Option
plot(t,y,'G');
  댓글 수: 2
rollcakes
rollcakes 2015년 10월 9일
thanks but graph is -3~ 3 maximum is 12 i think -1~4 maximum 4
TT
Star Strider
Star Strider 2015년 10월 9일
My pleasure.
If you want to define your rectpuls functions differently, you would get a different result for the convolution. For your functions as you defined them here, the result of your code (with my changes) is correct.

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

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by