I'm trying to solve numerically a problem like the next one: \begin{cases} y'(t) = x(t)+y(t) \\ x'(t) = x(t)-y(t) \\ x(0) = x_0 \\ y(T) = y_T \end{cases} with $t\in[0,T]$
I want to use ode45 in MATLAB, but in order to use it, the boundary conditions must be initial boundary conditons, so I can't use ode45 because $y(T) = y_T$.
I defined $\tilde{y}(t)=y(T-t)$, so $\tilde{y}'(t)=-y'(T-t)$ and $y(t)=\tilde{y}(T-t)$, then I got the following system
\begin{cases} \tilde{y}'(t) = -x(T-t)+\tilde{y}(T-t) \\ x'(t) = x(t)-\tilde{y}(T-t) \\ x(0) = x_0 \\ \tilde{y}(0) = y_T \end{cases}
and now I have initial boundary conditions. Now, the problem is that I have to evaluate $x$ and $\tilde{y}$ at $T-t$ and $t$, but that doesn't seem to be an option when I use ode45.
Any idea? I would appreciate any help.
Instead of trying to directly use
ode45, do it as a root-finding problem: finding $y(0)=y_0$ so that $y(T)=y_T$ when you solve the ODE.