Rocket release time error

조회 수: 9 (최근 30일)
al
al 2025년 1월 10일
댓글: al 2025년 1월 11일
Hello,
I made a previous post about a rocket simulation project I have. I am still stuck on the same project, but I managed to solve some of the problems. The current issue is some errors I get when I run problem c). My theory, after some debuging is that the issue is somwhere between row 260 and 271. Can anyone explain what these errors are from and how I can fix them?
Enter which problem ao run, a, c or d, enter problem: c
268 elseif tu<params_mini(3)
Index exceeds the number of array elements. Index must not exceed 4.
Error in testador>@(vx)(problem_main(5)*cosd(problem_param(5))-problem_main(4)*vx*V)/total_mass (line 311)
dvxdt = @(vx) (problem_main(5) * cosd(problem_param(5)) - problem_main(4) * vx * V) / total_mass;
Error in testador>Rungekutta (line 318)
k1vx = dvxdt(problem_param(3)); k1vy = dvydt(problem_param(4));
Error in testador>trajectory (line 269)
params = Rungekutta(params, user_inp, access_keys, dt_unrefined); % Runs mini rocket
Error in testador (line 32)
Height_distance = trajectory(params, user_inp, access_keys); % Pass params.c to rungekutta
  댓글 수: 3
al
al 2025년 1월 11일
Thanks for the help finding the issue!
I have now realised that the actual issue may occur much earlier, somwhere in row 215 to 231. It also seems I asigned position vector incorrectly. It was a 8x8 matrix instead of a 1x8 row vector. The main issue at the moment seems to be that the time counter tj for some reason can never exceed 3. My theory is that this later on causes errors, when we change our values to be the same as the values asigned to the current position array. This would explain why it suddenly drops from 4 to 0. Does anyone know how to resolve this error or if that is not the main cause?
New/updated code attached
al
al 2025년 1월 11일
I think I just solved it!
Thank you so much for the help! It seems the issue lied in the fact that I forgot to asign a value for when our time tj = 3. In previous code, this was never a big issue, since our time step was smaller and more percise. The issue was that the time will be exactly 3 and I never asigned a value/scenario on what to do when this happens.

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

답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by