I want to solve following ODE using Euler explicit method.
$$S'(t)=\frac{b}{m}\bigg(u(t)+\frac{P(t)}{p}\bigg)$$
where $S(0)=\frac{q}{m}$.
We can have any value for the parameters. $P(t)$ should be a non-decreasing function. I don't understand how to introduce the function in the program. Suppose $P(t)=t$ then what will be the formula of Euler explicit method?
MATLAB Code:
T = 10;
N = 100;
h = T/N;
b = -1;
q = 1;
m = 1;
p = 1.5;
S(0) = q/m;
S(1)=s(0);
for j=1:N
aj =(j-1)*h;
S(j+1)=(b*h/p*m)*t(j) + S(j);
end
I have written this code. I have taken the simplest case taking $u(t)=0$. But I am confused about $P(t)$. I have taken $P(t)=t$ as a non decreasing function. But how I have to introduced it? Do I have to give an initial value for t also?
For a step length of
h = T/N(note that in this form $N$ does not count the initial time $t=0$) the Forward Euler update equation reads in general formand for $u(t) \equiv 0$ and $P(t) = t$