How to avoid multiple file load in GUI?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Oliver Silva
am 22 Aug. 2016
Bearbeitet: Stephen23
am 22 Aug. 2016
I am doing a GUI and I am loading a .mat file with the data i need. So I call the file with load('file.mat') in the openingFcn. But when I want to use the data in another function like a callback button it does not find the variables and i have to load the file again in each function.
is there a specific place where I should load the file so it becomes global?
0 Kommentare
Akzeptierte Antwort
Stephen23
am 22 Aug. 2016
Bearbeitet: Stephen23
am 22 Aug. 2016
Every function (including callback functions) has its own workspace. Each workspace has its own variables: this is a good thing! Many beginners want all variables to exist in every workspace, but this is not a good way to manage data.
You can easily pass variables between workspaces:
Writing nested functions is probably the easiest way to pass data between callback functions. Otherwise guidata is a good method to pick.
If you are passing data between functions that are not callbacks, passing arguments is the simplest, fastest, and most reliable.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT Files 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!