Passing Data between Scripts and Functions
显示 更早的评论
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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!