Convolution of rect pulses with impulses
31 次查看(过去 30 天)
显示 更早的评论
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)
0 个评论
回答(1 个)
Arthi Sathyamurthi
2021-7-27
编辑:Arthi Sathyamurthi
2021-7-27
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!