COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### piecewise functions #3

• Follow

```I am trying to create a graph to show the value of a dosage in a patients blood in a given period of time if the patient is dosed every six hours.

From memory I had created a function along the lines of

function C=dosage(c0,t)
C=c0*exp(-0.5*t)
end

and then i had a script file which went something along the lines of

t=[0:0.1:24]
c0=2
plot(t, dosage(c0,t)
end
title('matlab assignments are really enjoyable')
xvalues('time in hours')
yvalues('dosage in blood mg/mL')

the above is possibly not the exact script file that I wrote, but anyway, if I wanted to write a function or script file that shows that 3 mg is added every three hours, how would I do this?
```
 0
Reply hamishok (1) 8/5/2012 9:40:20 AM

```On 8/5/2012 4:40 AM, ShowCain wrote:
> I am trying to create a graph to show the value of a dosage in a
> patients blood in a given period of time if the patient is dosed every
> six hours.
>  From memory I had created a function along the lines of
> function C=dosage(c0,t)
>   C=c0*exp(-0.5*t)
> end
> and then i had a script file which went something along the lines of
> t=[0:0.1:24]
> c0=2
> plot(t, dosage(c0,t)
> end title('matlab assignments are really enjoyable')
> xvalues('time in hours')
> yvalues('dosage in blood mg/mL')
>
> the above is possibly not the exact script file that I wrote, but
> anyway, if I wanted to write a function or script file that shows that 3
> mg is added every three hours, how would I do this?

function C=dosage(C0,dT,t)
C=C0*exp(-0.5*mod(t,dT);

dT is time between dosing assuming starting at t=0.

--

```
 0
Reply none1568 (6655) 8/5/2012 2:31:55 PM

```On 8/5/2012 9:31 AM, dpb wrote:
....

> function C=dosage(C0,dT,t)
> C=C0*exp(-0.5*mod(t,dT);
>
> dT is time between dosing assuming starting at t=0.
....

The above (obviously) doesn't account for residual level at next dosage,
though, only starting the clock over.

--

```
 0
Reply none1568 (6655) 8/5/2012 3:23:23 PM

2 Replies
22 Views

1/13/2013 9:39:22 AM