Using Matlab to do basic convultions

  • Thread starter Thread starter thatguy14
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

This discussion focuses on using MATLAB to perform convolutions for an imaging/physiological course. The user is tasked with convolving two functions: x(t) = 0.1 * t^1.5 * exp(-0.01 * t) and h(t) = 0.0001 * exp(-t/60). The correct MATLAB command for convolution is y = conv(x, h), which was initially miswritten as y = conv(x, t). The user seeks guidance on plotting the convolution result against time and determining the maximum concentration from the convolution output.

PREREQUISITES
  • Understanding of convolution in signal processing
  • Familiarity with MATLAB programming
  • Knowledge of function plotting in MATLAB
  • Basic concepts of pharmacokinetics related to absorption rates
NEXT STEPS
  • Learn how to use MATLAB's plot function to visualize convolution results against time
  • Research methods to determine the maximum value of a vector in MATLAB
  • Explore techniques for shifting functions in MATLAB for multiple convolution operations
  • Study the implications of convolution in pharmacokinetics and how it relates to drug concentration over time
USEFUL FOR

This discussion is beneficial for students and professionals in imaging, physiology, or pharmacokinetics who are using MATLAB for signal processing and convolution analysis.

thatguy14
Messages
45
Reaction score
0

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 I've 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 function. 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!
 
Physics news on Phys.org
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, don't really know how it got switched.

Anyways, that's 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?
 

Similar threads

Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K