functions don't take effect
Mostrar comentarios más antiguos
When calling a function involving multiple other functions where some changes are made, new changes don't take effect even when saving and running the newly changed function. What can one do?
12 comentarios
Sibghat
el 3 de Mzo. de 2024
Have you tried restarting MATLAB or the 'clear' function_name or clear functions method and running the code again?
Sometimes MATLAB might cache function definitions, and restarting MATLAB can refresh this cache, ensuring that the latest changes are recognized. You can also try clearing MATLAB's function cache using the clear functions command.
feynman feynman
el 3 de Mzo. de 2024
DGM
el 3 de Mzo. de 2024
Saving the file should be sufficient that it's updated, but you might want to double-check to make sure that the copy that's being saved is the same copy that MATLAB is using. Maybe that's a shot in the dark, but it's one possible explanation.
which function2
Steven Lord
el 3 de Mzo. de 2024
Another potential reason the changes may not be recognized is if you're storing your files under matlabroot. Leave that for MathWorks-provided files as MATLAB caches that directory.
feynman feynman
el 4 de Mzo. de 2024
feynman feynman
el 4 de Mzo. de 2024
feynman feynman
el 4 de Mzo. de 2024
Sibghat
el 4 de Mzo. de 2024
You can place the clear commands in your main.m script at the beginning or end of your main.m script before calling any functions. This way, every time you run the main script, it will clear any cached versions of the functions being called (function1.m and function2.m).
Sibghat
el 4 de Mzo. de 2024
@feynman feynman I think frequently adding paths can clutter the MATLAB search path with unnecessary directories. Although there are only two "addpath" commands in the provided code, if this code is executed repeatedly, it can result in the same directories being added to the MATLAB search path multiple times. Moreover,,if the directories being added contain functions or scripts with the same names, MATLAB may prioritize one over the other based on the order in which they're added to the path, leading to ambiguity and potential errors.
feynman feynman
el 4 de Mzo. de 2024
Respuestas (0)
Categorías
Más información sobre Search Path en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!