How to make a "local global " variable?
조회 수: 3 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!