ode45 - changing parameters & function handle

조회 수: 1 (최근 30일)
Andreas Theocharopoulos
Andreas Theocharopoulos 2019년 12월 21일
댓글: Andreas Theocharopoulos 2019년 12월 22일
I was given a full car model matlab code some time ago and today I decided to use it. The problem is that the code was written for a simple car with contant stiffness and damping throughout the whole suspension travel. I want to change this so that the stiffness and the damping coefficients change based on the values of displacement and velocity produced on previous step of the integration (included in the x output matrix). The solver used is ode45 and the damping-stiffness characteristics are saved together with some other specs concerning each corner of the vehicle on the wheel_1,wheel_2... matrices.
[t,x] = ode45(@FC_Solution_2,tt_f,initial,[],y,y,y,y,tt_f,wheel_1,wheel_2,wheel_3,wheel_4,body,hyst,frtrack,rrtrack,fz,mx,my,fz1,fz2,fz3,fz4);
I tried using the OutputFcn option but just couldn't get it to work, as every example related to this option I found was based on the classic ode45 syntax which I tried to follow but it didn't work.
Is the use of the anonymous function in my case causing the problem? Also I can't really understand why the '[]' is used when calling FC_Solution_2 as the head of this function is the following (23 vs. 22 input arguments):
function dxdt = FC_Solution_2(time,x,y1,y2,y3,y4,tt_f,wheel_1,wheel_2,wheel_3,wheel_4,body,late,frtrack,rrtrack,fz,mx,my,fz1,fz2,fz3,fz4)
Thanks for your time.

채택된 답변

Walter Roberson
Walter Roberson 2019년 12월 21일
obj = @(time,x) FC_Solution_2(time, x, y, y, y, y, tt_f, wheel_1, wheel_2, wheel_3, wheel_4, body, hyst, frtrack, rrtrack, fz, mx, my, fz1, fz2, fz3, fz4)
[t, x] = ode45(obj, tt_f, initial);
  댓글 수: 1
Andreas Theocharopoulos
Andreas Theocharopoulos 2019년 12월 22일
Thanks a lot for your answer Walter, this got me a step further. I can now use the OutputFcn with ode45. I will work around the code and some other examples I have found and I think I will find the solution for the main problem.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by