Legality of modifying built-in functions

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Steven Lord
Steven Lord il 5 Nov 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 Commento
Jakub Tomek
Jakub Tomek il 5 Nov 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).

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by