Convolution of rect pulses with impulses

29 visualizaciones (últimos 30 días)
Hakan Durak
Hakan Durak el 24 de Jun. de 2021
Editada: Arthi Sathyamurthi el 27 de Jul. de 2021
Hello friends i want to implement this scheme below but seems like i do something wrong cause i get wrong output.
can you help me what do i do wrong.
thanks in advance
Ts is 1, tau is 0.5s.
Ts=1;
fs=1/Ts;
fsample=100;
Tsample=1/fsample;
t=-5: Tsample :5; % time vector
y=zeros(size(t));
y(1:fsample/fs:end)=1;
h=heaviside(t+0.25)-heaviside(t-0.25);
s=conv(y,h);
plot(linspace(-5,5,length(s)),s)
x=exp(-t).*heaviside(t);
v=s*x;
plot(linspace(0,5,length(v)),v)

Respuestas (1)

Arthi Sathyamurthi
Arthi Sathyamurthi el 27 de Jul. de 2021
Editada: Arthi Sathyamurthi el 27 de Jul. de 2021
The error “Incorrect dimensions for matrix multiplication” obtained from simulating your code occurs when the two matrices have dimensions that cannot be multiplied. Click on this link to know more about the error.
Use the following code to resolve your error and to obtain the output as intended. Replace the last 3 lines of your code with the following code
x=exp(-t).*heaviside(t);
ts = -5: Tsample/2 :5; % time vector with equal number of data points as the variable s
x_interpolated = interp1(t,x,ts); % Interpolate x to have equal number of data points as s
plot(x_interpolated);
v=s.*x_interpolated; % The .* ensures each bit is multiplied correspondingly
plot(linspace(0,5,length(v)),v);

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by