fsolve wont take the initial guess

조회 수: 1 (최근 30일)
Nethanel Benzaquen
Nethanel Benzaquen 2020년 12월 7일
댓글: Nethanel Benzaquen 2020년 12월 7일
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
Stephan
Stephan 2020년 12월 7일
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 2020년 12월 7일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by