Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Using Matlab to do basic convultions

  1. Nov 8, 2011 #1
    1. The problem statement, all variables and given/known data
    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
    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).

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

    3. 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 (Text):
    t = linspace(0,10,100);
    a = 0.1;
    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!
  2. jcsd
  3. Nov 8, 2011 #2
    Code (Text):
    is convolving x against t. You need to convolve x with h, which would be

    Code (Text):
    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: Nov 8, 2011
  4. Nov 8, 2011 #3
    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?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook