mzbhura
mzbhura

Reputation: 393

How can I plot a convolution in MatLab?

Can anyone explain to me how I would go about plotting a convolution in MatLab?

The function I am trying to plot is e^(-at)u(t)*u*t)

Thanks!

Upvotes: 0

Views: 8013

Answers (1)

justGoscha
justGoscha

Reputation: 24136

The function for convolution of 2 arrays in Matlab is conv(array1, array2). But I do not fully understand, the mathematic expression that you are trying to convolve.

To get the plot you would do something like

plot(conv(array1, array2));

To convolve the unit step function u(t) with u(t)e^(-at) you have to create the array of the unit step function

u = ones(1,n);

and you also have to create the array of the other function. With a for-loop for example

e = zeros(1,n);
for i=1:n
  e(i) = u(i)*exp(-a*i)
end

then convolve both and plot.

Upvotes: 2

Related Questions