# solving piecewise functions using ode in matlab!!

Status
Not open for further replies.

#### cedance solving piecewise functions

Hi,

suppose, i define a function f'(t) = t at say [0,1] and f'(t) = t² at (1,4] that is,

f'(t) = t 0<=t<=1
= t² 1<t<=4

i need to find the numerical solution to this differential equation using matlab. Please suggest me how to do this. I couldnt find anything out of the help from matlab.

thanks,
cedance.

#### drabos

##### Full Member level 6 solving piecewise in matlab

Well, it is not numerical, but what about Laplace transformation?
And what about if you define the function with the aid of heaviside step function?
e.g.: [0,1] : Heaviside(t)-Heaviside(t-1)

#### drabos

##### Full Member level 6 solving piecewise functions values

or you write two equations, as you did .
You know the initial conditions for the first equation, so you can calculate the solution of the first equation. You will get the initial values for the second equation, then you can calculate the second equation and after you can merge the two solution vectors. What about this approach?

Status
Not open for further replies.