Central difference method to obtain solutions for derived Equations of Motions of UAV aircraft

41 views (last 30 days)
Having trouble find a way to use the central difference method to obtain solutions for nonlinear derived Equations of Motion (EOM) of a UAV aircraft. I have already derived the Equations of Motions but just not sure if I am doing the coding correctly to obtain the solution for the EOM using the time integration method (Central difference method). Can anyone help please
  7 Comments
Taikiko Taukei
Taikiko Taukei on 12 Apr 2024 at 9:21
@Torsten and @John D'Errico the problem I am facing is that every time I try to run the central differece method code this message appears:
Index exceeds the number of array elements. Index must not exceed 1000.
Error in UAS_3DOF_Longitudinal_CDM (line 44)
du_dt = (1/(2*dt)) * (u(i-1) - u(i+1));
Torsten
Torsten on 12 Apr 2024 at 10:55
Edited: Torsten on 12 Apr 2024 at 10:55
Didn't you read my response ?
You try to use a value in the computation of du_dt that is not yet known, namely u(i+1).
If you hadn't initialized the arrays as
u = zeros(num_steps, 1); % velocity array
alpha = zeros(num_steps, 1);% angle of attack array
q = zeros(num_steps, 1); % pitch rate array
the above error message would have popped up already for i = 2. Now it appears for i = N because the above arrays are only initialized up to index N, but you try to access u(N+1).
It would be interesting to know how the central difference method to solve ODEs works correctly. I cannot find it anywhere in the web.

Sign in to comment.

Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!