Matlab convoluton plotting I need help with a small bit of t

Matlab convoluton plotting

I need help with a small bit of this code. I am plotting the convolution of the singal but then i get the error reading:

Error using plot
Vectors must be the same length.

Error in Lab1P2_Campos (line 24)
plot(x,new_s,\'linewidth\',2);

Script:

t=-8:0.001:8;

s1 = rectpuls(t);
s2 = rectpuls(t/3);

new_s=conv(s1,s2);

plot(t,new_s,\'linewidth\',2);

Do I redfine t to double the length to meet the new length of new_s? Kinda confused here

Solution

clc;

clear all;

close all;

t=-8:0.001:8;

s1 = rectpuls(t);

figure;

plot(t,s1);

title(\'s1(t)\');

s2 = rectpuls(t/3);

figure;

plot(t,s2);

title(\'s2(t)\');

convtime=(-16:0.001:16);

new_s=conv(s1,s2);

figure;

plot(convtime,new_s,\'linewidth\',2);

title(\'convolution signal\');

While executing your program the error came as \" Vectors must be same length \".

After the convolution the time periods must be double. for signal s1: time period from -8:0.001:8;

and for s2: -8:0.001:8 ; for the convolution of those signals their time ranges will be added up in the convolution signal;

the convolution signal time range is from : -8-8: 0.001 : 8+8

ie., -16:0.001:16

So, by considering another time variable from the above range and plot the convolution signal.

Matlab convoluton plotting I need help with a small bit of this code. I am plotting the convolution of the singal but then i get the error reading: Error using
Matlab convoluton plotting I need help with a small bit of this code. I am plotting the convolution of the singal but then i get the error reading: Error using

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site