use variables of one .m file in another .m file

209 vues (au cours des 30 derniers jours)
Elise
Elise le 4 Juin 2014
Réponse apportée : Sara le 4 Juin 2014
Hi all!
I want to have one .m file declaring a lot of constants and use these constants in my other .m files. Such that if I want to change these constants, I only have to change one file, and not have to go through all my .m files. Is this possible?
Thanks a lot!

Réponse acceptée

Sara
Sara le 4 Juin 2014
You can define the constants in one file and save them in a mat file:
save('myfile.mat','name_var1','name_var1')
and read in this file in the other m-files:
load('myfile.mat')

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by