how do i re-run a script so that it takes the updated information from another script?

18 visualizaciones (últimos 30 días)
i have 2 scripts open. The first one includes my function. In the second script that calls on my function. If i run the code in the second script and then go back to first script and adjust some of the code, when i go back to second script to run, it doesnt notice the update i made in the first script. The way i have gotten around this is running "clear" and then starting from scratch, but i am assuming there is a cleaner way to do this?
  1 comentario
per isakson
per isakson el 17 de Ag. de 2019
Editada: per isakson el 17 de Ag. de 2019
IMO: Your "program" (/system) shall consist of at most one script (the "main") together with any number of functions. Many collaborating scripts is asking for trouble.
Proposal: Show us your code or better make a minimal working example that illustrates your problem. Then we could try to cast it into a better design.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 17 de Ag. de 2019
MATLAB will normally notice changes to .m files that are on the current path, but not if they are installed under the MATLAB installation directory, and not consistently if you are working with a function handle to the function.
Using clear with the name of the function is the official method of dealing with this.
  2 comentarios
Samir Mobasher
Samir Mobasher el 17 de Ag. de 2019
thanks. So i have a series of .m files in my current folder. I am completing a course where one of the main files has the majority of the code/instructions, it asks you to then go into the other .m files and input various code for functions. Once that is complete you come back to the main file and run the section of code that relates to that file. My issue is if i have gotten my code wrong and i try to change when i come back main file it doesnt recognise the change. So i normally have to clear everything. I will attempt clear with the function name thanks.
Samir Mobasher
Samir Mobasher el 17 de Ag. de 2019
similarly if i have code in a particular .m file and then i adjust that code and run the function in the command window, its not recognizing the adjusted code, just the code that existed before.

Iniciar sesión para comentar.

Categorías

Más información sobre Software Development Tools en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by