Prev: Caliper reading using RS-232 -project help
Next: undefined function error in 2009a, but not in 2009b
From: Steven Lord on 11 Feb 2010 13:23 "Heather Moreland" <heather.moreland(a)gmail.com> wrote in message news:hl1d88$j0n$1(a)fred.mathworks.com... >I am finding the documentation difficult to decipher in terms of how to >define the approprate function myfun. > > I have create an m-file with > > function=status=myfun( ) You have one too many equals signs in your function declaration line. > but I am not sure what the arguments should be or how to define them to > achieve the desired result. Quoting from the documentation page: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/odeset.html#f92-1016858 "The output function must be of the form status = myfun(t,y,flag)"Refer to the table just below that line to see what flags your function should handle. If you're new to MATLAB and aren't entirely familiar with how to write functions (or if it's been a while and you're a bit rusty) I recommend you review the Getting Started section of the documentation that talks about how to create functions. http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-2525.html You can use the rank.m example on that page as an example of how your function should be set up. Just make sure it accepts three input arguments (which the doc refers to as t, y, and flag) and returns an output (which the doc calls status.) -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Heather Moreland on 11 Feb 2010 14:34 > "The output function must be of the form > status = myfun(t,y,flag)"Refer to the table just below that line to see what > flags your function should handle. > > If you're new to MATLAB and aren't entirely familiar with how to write > functions (or if it's been a while and you're a bit rusty) I recommend you > review the Getting Started section of the documentation that talks about how > to create functions. > > http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-2525.html > > You can use the rank.m example on that page as an example of how your > function should be set up. Just make sure it accepts three input arguments > (which the doc refers to as t, y, and flag) and returns an output (which the > doc calls status.) > I am familiar with writing functions in matlab, however I find this help menu completely unhelpful. What are t, y, and flag? If the flags can only be thing items listed in the table, I do not see how this will accomplish what I need. I need to know how ode15s calls its time step in order to define t in the function call. I might add that it should be clear by being on this site that I have looked at the help menus and did not find them helpful. Therefore, simply quoting the help menus is not at all productive for me ( or anyone else for that matter).
From: Steven Lord on 13 Feb 2010 16:48 "Heather Moreland" <heather.moreland(a)gmail.com> wrote in message news:hl1m3c$1n1$1(a)fred.mathworks.com... >> "The output function must be of the form >> status = myfun(t,y,flag)"Refer to the table just below that line to see >> what flags your function should handle. >> >> If you're new to MATLAB and aren't entirely familiar with how to write >> functions (or if it's been a while and you're a bit rusty) I recommend >> you review the Getting Started section of the documentation that talks >> about how to create functions. >> >> http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-2525.html >> >> You can use the rank.m example on that page as an example of how your >> function should be set up. Just make sure it accepts three input >> arguments (which the doc refers to as t, y, and flag) and returns an >> output (which the doc calls status.) >> > I am familiar with writing functions in matlab, however I find this help > menu completely unhelpful. What are t, y, and flag? That depends on the flag value. If the ODE solver calls the OutputFcn with the 'init' flag, then t and y are the tspan vector and the y0 vector you specified in your call to the ODE solver. If the flag is [], t is the time of the current step and y is the value of the solution of the system at that time step. Finally, if the flag is 'done' ... well, the documentation doesn't specify what t and y are in that scenario. I'll ask the documentation staff to add that to the documentation. > If the flags can only be thing items listed in the table, I do not see how > this will accomplish what I need. I need to know how ode15s calls its > time step in order to define t in the function call. Okay, now I think I understand. I interpreted your original description as "I want to see the value after each time step ODE15 takes" (for which the OutputFcn is the best approach), not "I want my function to be able to use the values from previous time steps." Those are two different beasts entirely. Am I correct that the latter is what you want? If so, you cannot do this with ODE15S -- you will need a delay-differential equation solver, like DDE23 or DDESD. > I might add that it should be clear by being on this site that I have > looked at the help menus and did not find them helpful. It wasn't clear from your previous posts how thoroughly you'd read the documentation or what part of the documentation you'd read, and because it's not always the case in general that people only post here after reading through the documentation (indeed, you're in the minority) I did not assume you had. Was there a particular portion of the OutputFcn documentation that you feel could be improved? If so, please use the buttons at the lower-right corner of the page to offer your suggestions for improvement -- that feedback goes right to the documentation staff. > Therefore, simply quoting the help menus is not at all productive for me > ( or anyone else for that matter). On the contrary -- many people ask questions that can be easily answered with the name of a function they've never used before and/or a quote from the documentation that they skimmed over, overlooked, or just didn't read at all. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
First
|
Prev
|
Pages: 1 2 Prev: Caliper reading using RS-232 -project help Next: undefined function error in 2009a, but not in 2009b |