Passing Data between Scripts and Functions
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Coopinator
am 16 Apr. 2015
Beantwortet: Stalin Samuel
am 16 Apr. 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 Kommentare
Akzeptierte Antwort
Stalin Samuel
am 16 Apr. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!