Passing Data between Scripts and Functions
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Coopinator
le 16 Avr 2015
Réponse apportée : Stalin Samuel
le 16 Avr 2015
Hello,
I have a simple question about loading data into functions. Right now I have a script that executes several functions that I have written. These functions require data from a structure array that I have saved as a .m file. Ideally, the conceptual flow of the script that I am trying to achieve is:
(1) load data from .m file
(2) execute function1()
(3) execute function2()
(4) execute function3()
(5) return output
Thus, I would load the data once in the script and then all of the functions could use it. Right now the script does not work like this, presumably because of some issue with the scope of the variables. The script works fine if I load the data in each function individually, but this is cumbersome and not very flexible. Ultimately I would like to add user input to the script such that the user selects which data set to load once and then all the functions refer to this data set. Thanks in advance.
0 commentaires
Réponse acceptée
Stalin Samuel
le 16 Avr 2015
1) load data from .m file
(2) out1 = function1(arg11,arg12) %arg11,arg12 are the data from file which used within function 1
(3) out2 = function2(arg21,arg22)%arg21,arg22 are the data from file which used within function 2
(4) out3 = function3(arg31,arg32)%arg31,arg32 are the data from file which used within function 3
%%out1,out2,ou3 are function outputs
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps 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!