I'm having a problem solving a NDF using fsolve with an event. There are 2 variables y(1) and y(2) where we need to do an order reduction getting a total of 4 variables to the ODE problem. Objective of the code is to find when will both variables be equal to x_wall. The code is as such
Y=fzero(@(x) solver(t_step, t_interv, x, x_wall), y0 );
function F= solver(t_step, t_interv,x, x_wall)
[t,y] = MY_RK4_event(@My_DoublePendulum, t_step, t_interv, x, x_wall);
X2 = X1+sin(y(2,end))*l2;
F=[X1 X2 0 0]-[x_wall x_wall 0 0];
I keep getting an error saying that i can only input 2 inputs to the solver, and when inputing 2 inputs the fsolve only send in y0(1) as variable x in the function solver.