Issues with other scripts accessing workspace variables
조회 수: 7 (최근 30일)
이전 댓글 표시
Hello,
I have pre-defined a set of variables in one .m file and written a function in another file that needs to use some of these variables. I ran the variables file, can see the variables stored in the workspace, and yet when I try to run the functions they do not recognize the variables. Any ideas?
I have attached a picture. It shows the variables storing file, the workspace with said stored variables, and an error that appears in the command window when the functions try to call the workspace variables.
Thank you.

댓글 수: 1
답변 (1개)
dpb
2025년 3월 24일
<function>s have an independent workspace from the base workspace. See <Base and Function Workspace> and the reference linked to there that shows best practice is to pass arguments to your functions.
댓글 수: 0
참고 항목
카테고리
Help Center 및 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!