Legality of modifying built-in functions

1 visualización (últimos 30 días)
Jakub Tomek
Jakub Tomek el 5 de Nov. de 2019
Comentada: Jakub Tomek el 5 de Nov. de 2019
I'm not sure if I'm reading the licence agreement correctly, but is it so that it is not allowed to modify Matlab's built-in functions? At the same time, there are questions here with staff answers sounding like this is nothing that would not be allowed.
I would like to modify an ODE solver ode15s to allow the premature termination in case its runtime takes too long. I wouldn't distribute the code. Can I do this?
Many thanks.
  2 comentarios
Jakub Tomek
Jakub Tomek el 5 de Nov. de 2019
Thank you, that's a neat use of events!

Iniciar sesión para comentar.

Respuesta aceptada

Steven Lord
Steven Lord el 5 de Nov. de 2019
For questions about the license agreement you should contact Customer Service using the telephone icon in the upper-right corner of this page.
For the technical question about the ODE solver, you don't need to modify ode15s to do what you want. Something like this should work:
  1. Write an events function that has a persistent variable inside it or that is nested inside another function.
  2. The first time the events function is called, it should store the current date and time (datetime('now')) in the persistent variable or a variable in the nested function's parent function.
  3. Each subsequent time the events function is called, it should check if enough time has elapsed since the saved date and time. If it has, the events function should report a terminal event to the ODE solver.
  4. Once the ODE solver has completed execution, clear the events function to clear the persistent variable.
Note that this won't stop the ODE solver immediately when your time limit is reached, but it will tell the ODE solver to stop as soon as possible.
  1 comentario
Jakub Tomek
Jakub Tomek el 5 de Nov. de 2019
Thank you, Steven for the reply and advice!
(For the record, I did try to contact the Customer Service using the telephone first, but was told that there was nobody available to talk to).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by