How to access and change variables in workspace

조회 수: 4 (최근 30일)
tommsch
tommsch 2020년 11월 30일
편집: tommsch 2020년 11월 30일
I need to access variables in a workspace which are in a workspace down the stack. And I need to do this in a function - Thus, start the debugger, select the workspace manually and change the variable is not the thing I want to do. Thus, I need to do something like
evalin( 'caller', evalin( 'caller', evalin( ..., variablename) ) ... ).
I am open for hacky solutions too.
Furthermore: Please do not tell me any of the following: "Do not use eval", "Do not use global variables", "Don't do this" etc.. I am not a novice programmer (and hate that in similar questions the answer is never given, but only told that one should not do it).
  댓글 수: 7
Steven Lord
Steven Lord 2020년 11월 30일
This is for a testing framework, in particular for testing legacy code.
Are you building this on top of the testing framework included in MATLAB?
How exactly is retrieving data from workspaces lower in the stack going to help with your testing framework? Your test functions are going to call the software under test. For it to have access to variables from the subfunctions you'd have to have the test function executing at the same time as the subfunction and have that test function access the callee's workspace not the caller's.
tommsch
tommsch 2020년 11월 30일
편집: tommsch 2020년 11월 30일
I am not fully satisfied with the Matlab testing framework, since I think its quite verbose and does lack some important features, expecially for testing scientific software. Thus, I am mostly writing extra assertions on top of the matlab framework. (Edit: assertition framework would thus be the better name)
The thing I want to do is tracing.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Testing Frameworks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by