# Using Matlab to do basic convultions

## Homework Statement

This is more of a imaging/physiological course but it uses convolutions and i can understand the applications, i just need help writing the matlab script to give meaningful answers.

The problem asks that we use matlab to convolute 2 functions:

x(t) = a*tb*exp(-ct)
where a=0.1 b=1.5 c=0.01
and
h(t) = dexp(-t/r)
where d = 0.1ml-1 and r = 60 min

There are units for x = micrograms/min. (this means d has to = 0.0001) x(t) is the absorption rate and h(t) is the impulse response function. y(t) would equal the concentration.

The idea is to plot y(t) using the matlab conv function for x(t) and h(t).

## Homework Equations

Im not sure what goes here ive given most of the information above.

## The Attempt at a Solution

I am not very good with matlab but what i did was create a time vector using the linspace fucntion. Heres the script

Code:
t = linspace(0,10,100);
a = 0.1;
b=1.5;
c=0.01;
alpha=0.1;
tao=60;
x=a.*t.^b.*exp(-c.*t);
h=alpha.*exp(-t./tao);
y=conv(x,t);
plot(y)

When i plot y, the y axis and the x axis give numbers that don't make sense in the terms of the question. atleast i don't think they make sense. Have i done this right?

Thanks for the help!

Code:
y=conv(x,t);
is convolving x against t. You need to convolve x with h, which would be

Code:
y=conv(x,h);

Plot is just plotting the points in Y and connecting them with a line. Since you don't tell matlab what x is, it just plots the values against the array index.... so the first point is 1, the second is 2, etc....

The Y vector is 200 elements big because of how the convolution works. Since it has to sweep one function completely over the other, and the two arrays are the same length, the output array is twice as long -1. Think about it starting with the two functions side by side (with one flipped backwards), stepping through until they are side by side again, but on opposite sides.

Last edited:
Ok i see, it was actually a typo the y=conv(x,t). I had it set in my script as x and h, dont really know how it got switched.

Anyways, thats a much better looking shape. The y axis units are better too. How would i plot the convolution function againt time in this case? Also this convolution would in essence give me my maximum concentration (it is derived from the meaning of x and h). How do i determine its maximum?

Also the second part of this question requires that i take multiple conv functions that have been shifted by some time and add them together. I understand that i have to take my x function and h function and shift it by the dosage, but how do i add these functions together in the convolution for multiple shifts?