MATLAB: I want draw x(t) h(t) y(t) in just one plot window

convolutionMATLAB

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

Best Answer

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');