fsolve wont take the initial guess

2 visualizaciones (últimos 30 días)
Nethanel Benzaquen
Nethanel Benzaquen el 7 de Dic. de 2020
Comentada: Nethanel Benzaquen el 7 de Dic. de 2020
Hello,
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
y0 = [pi/8 1 0 0]; %inital guess
t_step = 0.1; %time step
t_interv = [0 10];
x_wall = -0.5; %final position
Y=fzero(@(x) solver(t_step, t_interv, x, x_wall), y0 );
function F= solver(t_step, t_interv,x, x_wall)
l1=1;l2=1;
[t,y] = MY_RK4_event(@My_DoublePendulum, t_step, t_interv, x, x_wall);
X1 = sin(y(1,end))*l1;
X2 = X1+sin(y(2,end))*l2;
F=[X1 X2 0 0]-[x_wall x_wall 0 0]; %final condition
end
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.
Why?
  5 comentarios
Stephan
Stephan el 7 de Dic. de 2020
Maybe my english language knowledge is to poor, but did you notice that you use fzero:
Y=fzero(@(x) solver(t_step, t_interv, x, x_wall), y0 );
instead of fsolve? Is it that simple?
Nethanel Benzaquen
Nethanel Benzaquen el 7 de Dic. de 2020
no where looking for the values of y(1) and y(2) that will give will satistfy the final event where both ends of a double pendulum will hit a wall placed at x=-0.5.
I get ur answer thanks a lot! I will pass it on to my proffesor to correct the question

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by