MATLAB Answers

0

anyway to clear variable in Matlab workspace from app?

Yu Li 님이 질문을 제출함. 31 Aug 2019
최근 활동 Yu Li 님이 댓글을 추가함. 1 Sep 2019
Hi:
is there anyway to clear variable in Matlab workspace from app designer?
an workaround I know is to use 'assign' function, to assign an empty value to that variable. but I want know how to clear it.
Thanks!
Yu

  댓글 수: 2

There should be no need to clear variables from any workspace from within a different workspace. If there is a need to do this, it raises red flags that something is being done in a bad way. Could you explain why you need to clear an external workspace?
There is rarely a need to clear variables from within a function but sometimes it useful to do so. There should never be a need to clear variables in a different workspace. Without knowing more about what you're doing, the best help I can offer is trying to clean up any reasons why someone would need to do this in the first place.
What workspace is the variable in (the base workspace?), how did it get there, and why does it need to be cleared from within a function (which has its own workspace).

로그인 to comment.

답변 수: 2

Walter Roberson 님의 답변 31 Aug 2019
 채택된 답변

evalin('base', 'clear VARIABLENAME')

  댓글 수: 4

표시 이전 댓글 수: 1
It has been known for people to use the existence of a variable as a state flag. Even people who should know better sometimes slip into that, such as creating an environment variable whose existence signifies that some particular debugging is to be done.
I see. Thanks!
Thank you Walter, this is exactly what I need.
Adam: thank you the same. I need this feature to translate data between workspace and appdesigner.
Bests,
Yu

로그인 to comment.


R.G. 님의 답변 31 Aug 2019

To clear variable use 'clear' function instead, ex:
clear('v')
where 'v' is variable name.

  댓글 수: 3

clear() can only clear a variable within the workspace in which it is called. The question indicated that the goal was to clear a variable from another workspace which is not possible with clear().
Not my question, look at topic starter's nickname :)
So, if Yu Li can assign, then he can clear also.
Sorry, RG! Not sure how I made that mistake! I fixed my comment.

로그인 to comment.



Translated by