How to Make a Huge Struct Accessible to Many Functions?
Ältere Kommentare anzeigen
I have a huge struct loaded by a function. I have other functions that will use some of the fields of the struct to calculate something. What is the best way to make this struct accessible to all other functions? More info: this struct will only be read and no information by other functions will be overwritten on it.
1 Kommentar
Adam
am 17 Mär. 2017
I'm not really sure how this question differs from this one where you appeared to be asking the same thing and Steven Lord gave you a link that explains about sharing between callbacks.
The answer in general is still the same, though with specific code, which you haven't included, may vary.
The fact that you have a 'huge struct' needed by many functions in the first place sounds like the start of the problem. Functions should ideally be given no more than they need to perform their own task within the overall system.
Akzeptierte Antwort
Weitere Antworten (2)
KSSV
am 17 Mär. 2017
0 Stimmen
Read about global. Make your structure a global variable, hence you can access in any function without sending into the function.
Image Analyst
am 17 Mär. 2017
0 Stimmen
Kategorien
Mehr zu JSON Format finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!