From: Aysegul Cilli on 13 Apr 2010 07:32 Hello, I am using ode functions and want to stop the execution of the function when, some parameters I calculate in ode function reaches values which are limits for my system. For example, I am calculating distance using ode45 as a mid-step and want to stop execution of ode45 function when x=100m although the time I desired to perform the calculations has not been up yet. However I do not want Matlab to give an error message but to continue execution of the main program from the following row of the ode45 function. I know that "break", "end" or "return" commands can not succeed this. How can I solve this problem? Thanks, Aysegul
From: Steven Lord on 13 Apr 2010 09:21 "Aysegul Cilli" <aysegulcilli.remove.this.(a)gmail.com> wrote in message news:hq1ko3$a3$1(a)fred.mathworks.com... > Hello, > > I am using ode functions and want to stop the execution of the function > when, some parameters I calculate in ode function reaches values which are > limits for my system. For example, I am calculating distance using ode45 > as a mid-step and want to stop execution of ode45 function when x=100m > although the time I desired to perform the calculations has not been up > yet. However I do not want Matlab to give an error message but to continue > execution of the main program from the following row of the ode45 > function. > > I know that "break", "end" or "return" commands can not succeed this. How > can I solve this problem? Use an Events function. See the BALLODE demo for an example that does pretty much exactly what you describe for the problem of a ball that falls and bounces off the ground. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Aysegul Cilli on 16 Apr 2010 08:43 "Steven Lord" <slord(a)mathworks.com> wrote in message <hq1r4m$ojq$1(a)fred.mathworks.com>... > > "Aysegul Cilli" <aysegulcilli.remove.this.(a)gmail.com> wrote in message > news:hq1ko3$a3$1(a)fred.mathworks.com... > > Hello, > > > > I am using ode functions and want to stop the execution of the function > > when, some parameters I calculate in ode function reaches values which are > > limits for my system. For example, I am calculating distance using ode45 > > as a mid-step and want to stop execution of ode45 function when x=100m > > although the time I desired to perform the calculations has not been up > > yet. However I do not want Matlab to give an error message but to continue > > execution of the main program from the following row of the ode45 > > function. > > > > I know that "break", "end" or "return" commands can not succeed this. How > > can I solve this problem? > > Use an Events function. See the BALLODE demo for an example that does > pretty much exactly what you describe for the problem of a ball that falls > and bounces off the ground. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > Thanks for your advice. It helped me very much. But can you give also an advice for any method/function for using with ode4 function serving the same purpose? I know that we can not give ode4 function "options" data as we do with ode45. Or, can I use events function with also ode4 function?
From: Steven Lord on 16 Apr 2010 09:22 "Aysegul Cilli" <aysegulcilli.remove.this.(a)gmail.com> wrote in message news:hq9m0s$385$1(a)fred.mathworks.com... > "Steven Lord" <slord(a)mathworks.com> wrote in message > <hq1r4m$ojq$1(a)fred.mathworks.com>... >> >> "Aysegul Cilli" <aysegulcilli.remove.this.(a)gmail.com> wrote in message >> news:hq1ko3$a3$1(a)fred.mathworks.com... >> > Hello, >> > >> > I am using ode functions and want to stop the execution of the function >> > when, some parameters I calculate in ode function reaches values which >> > are limits for my system. For example, I am calculating distance using >> > ode45 as a mid-step and want to stop execution of ode45 function when >> > x=100m although the time I desired to perform the calculations has not >> > been up yet. However I do not want Matlab to give an error message but >> > to continue execution of the main program from the following row of the >> > ode45 function. >> > >> > I know that "break", "end" or "return" commands can not succeed this. >> > How can I solve this problem? >> >> Use an Events function. See the BALLODE demo for an example that does >> pretty much exactly what you describe for the problem of a ball that >> falls and bounces off the ground. >> >> -- >> Steve Lord >> slord(a)mathworks.com >> comp.soft-sys.matlab (CSSM) FAQ: >> http://matlabwiki.mathworks.com/MATLAB_FAQ > > Thanks for your advice. It helped me very much. But can you give also an > advice for any method/function for using with ode4 function serving the > same purpose? I know that we can not give ode4 function "options" data as > we do with ode45. Or, can I use events function with also ode4 function? I don't know; I don't use really ODE4. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
Pages: 1 Prev: nested statistic toolbox dataset's Next: help in simulink |