ode output function problem

1 回表示 (過去 30 日間)
Baha411
Baha411 2019 年 5 月 16 日
コメント済み: Baha411 2019 年 5 月 17 日
Hi,
I am using an output function for ode32s and I have a question regarding outputFcn.
Matlab ver 2018b,
On line 288 of ode32s:
feval(outputFcn,[t tfinal],y(outputs),'init',outputArgs{:});
On line 515 of ode32s however:
stop = feval(outputFcn,tout_new,yout_new(outputs,:),'',outputArgs{:});
Code is failing for too much input b/c in the latter there is one input missing with ''
Can you help me what's going on here?

採用された回答

Steven Lord
Steven Lord 2019 年 5 月 16 日
As documented in the odeset function documentation page the function you specify as your custom OutputFcn must have a certain syntax and must accept certain types of calls.
"If you write a custom output function, then it must be of the form
status = myOutputFcn(t,y,flag)
The output function must also respond appropriately to these flags:"
You haven't provided much detail about the problem you're experiencing, but I suspect your custom OutputFcn does not conform to this requirement because it fails to accept the flag input argument.
  7 件のコメント
Steven Lord
Steven Lord 2019 年 5 月 16 日
This is a different problem than your original question. In the case where ode23s calls your output function with the '' flag, it must return an output telling ode23s whether or not to continue solving the ODE. From the documentation:
myOutputFcn must return a status of 0 or 1. If status = 1, then the solver halts integration. You can use this mechanism, for instance, to implement a Stop button.
Your myOutputFcn doesn't return anything, I assume?
Baha411
Baha411 2019 年 5 月 17 日
Yes, my myOutputFcn function doesn't return anything.
Yes, status is needed.
Thanks for your help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by