MATLAB: I want to multiply the given function(sin function) with the impulse signal,,but i’m not getting the product part after multiply both function and signal..Here is the code.

MATLAB

%delta signal
T= 0:99;
n=[zeros(1,49),1,zeros(1,50)];
figure(1);
stem(T,n);
xlabel('t');
ylabel('DELTA');
%sinwave fxn
A=1;
T=0:0.01:1;
f=3;
Y3=(A*sin(2*pi*f*T));
figure(2);
plot(T,Y3);
%product
T=0:0.01:1;
X3=Y3.*n;
figure(3);
stem(T,X3);

Best Answer

Variable T= 0:99 has a length of 100, whereas T=0:0.01:1 has a length of 101. You need to make them of equal lengths. Also, I am not sure why you are defining it as T= 0:99 initially. It is better that you use the same T vector.
%delta signal
T= 0:0.01:1;
n=[zeros(1,50),1,zeros(1,50)];
figure(1);
stem(T,n);
xlabel('t');
ylabel('DELTA');
%sinwave fxn
A=1;
f=3;
Y3=(A*sin(2*pi*f*T));
figure(2);
plot(T,Y3);
%product
X3=Y3.*n;
figure(3);
stem(T,X3);