Show variable value of subfunction in workspace.
조회 수: 4 (최근 30일)
이전 댓글 표시
Please suggest how to show subfunction variable value in the worksapce that are called in the main function. When i run main function workspace shows only main function's variable value, not shows variable value that are in the subfunction.
댓글 수: 0
답변 (1개)
Stephen23
2018년 5월 18일
편집: Stephen23
2018년 5월 18일
"When i run main function workspace shows only main function's variable value, not shows variable value that are in the subfunction."
That is exactly what should happen. Every function has its own independent workspace, and any variables inside that workspace are only available there... unless you explicitly pass them to another workspace. See:
The easiest and most efficient way to pass values from one workspace to another is to pass them as input/output arguments, e.g. to define the function with the required arguemnts:
function [AA,BB,CC,..] = myfun(XX,YY,ZZ,...)
and call it with those arguemnts:
[outA,outB,outC,...] = myfun(inX,inY,inZ,...)
For more details see:
As the documentation advises, do NOT use global variables, assignin, evalin, etc.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!