Error using odeset "Not Enough Input Arguments"

1 回表示 (過去 30 日間)
Andrew Pearson
Andrew Pearson 2020 年 12 月 4 日
コメント済み: Andrew Pearson 2020 年 12 月 6 日
I'm working on a project for one of my classes and I came across an error that I haven't been able to solve for some time now. ODE45 and the odeset functions are all way beyond my expertise, but I'm required to use them to solve a bottle rocket trajectory problem.
The exact error is as follow:
% Not enough input arguments.
% Error in Project2_2012>change (line 88)
yposbool = (0 > ini(2));
% Error in Project2_2012 (line 63)
[t,Y] = ode45(@(t,X) rocket(t,X),tspan,ini,change);
The ode solver is supposed to stop once the rocket hits the ground, and I've compared myself to other students who have a similar setup, though nothing I try seems to work. I know its probably something really simple, but my knowledge of MatLab is limited and the documentation of this function is way beyond me.
Code is provided in the link as it sits around 200 lines of code.
https://drive.google.com/file/d/1cTsddlJtLJj3twnNlfVn0kr3bx4Fu8YK/view?usp=sharing
Any help is much appreciated!!! :)

採用された回答

Steven Lord
Steven Lord 2020 年 12 月 4 日
[t,Y] = ode45(@(t,X) rocket(t,X),tspan,ini,change);
Based on the error message, change is a local function (a subfunction) inside your main Project2_2012 file. I suspect you intend this to be used as an events function. If my suspicion is correct, that's not the correct way to specify an events function. Take a look at the ballode.m example file. It solves an ODE with an event function (that detects when a bouncing ball strikes the ground and causes it to bounce) and you can try using it as a model for the solution to your system of ODEs. Though you're probably going to want your program to simply stop rather than have your rocket bounce.
  1 件のコメント
Andrew Pearson
Andrew Pearson 2020 年 12 月 6 日
Thank you so much! It was something really simple, the advance function was supposed to be used in the ode45 call for the event instead of change.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by