2
votes

This plots but the result of conv is a vector of a new length and so t is usless to include in plot like plot(t, z1) %doesn't work!.

t = [-5:.1:10];
unit = @(t) 1.*(t>=0);

h1 = @(t) (3*t + 2).*exp(-3*t).*unit(t);
z1 = conv(unit(t), h1(t));

plot(z1);

I want a plot of the convolved signal as a function of time.

1

1 Answers

2
votes

You need to add the shape argument. Here's the spec:

— Function File: conv (a, b) — Function File: conv (a, b, shape) Convolve two vectors a and b.

The output convolution is a vector with length equal to length (a) + length (b) - 1. When a and b are the coefficient vectors of two polynomials, the convolution represents the coefficient vector of the product polynomial.

The optional shape argument may be

shape = "full" Return the full convolution. (default) shape = "same" Return the central part of the convolution with the same size as a.

so convolve like this:

z1 = conv(unit(t), h1(t), "same");

And you'll get the same time units as the original.