How to make a "local global " variable?
4 次查看(过去 30 天)
显示 更早的评论
Hello,
I would like to share some variables among some functions. It is inconvenience to make them all as arguments, because that makes the command too long. Is there a way to add these variable in a special "global variable pool"? A global variable is defined under all functions, which is not appropriate for me. I only want them to be shared among several functions.
Thank you for any helpful suggestion.
3 个评论
Rik
2019-5-31
@Stephen since using a struct is likely to be the best solution by far, I would suggest you move it to the answers section.
采纳的回答
Walter Roberson
2019-5-31
No, that does not exist.
- you can create accessor functions that deal with persistent variables inside a private directory
- you can put the functions togther in a class with class variables
- if all relevant functions can be in the same source file, then you can use nested functions with shared variable
- or pass a struct instead
0 个评论
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!