anyway to clear variable in Matlab workspace from app?
21 次查看(过去 30 天)
显示 更早的评论
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 个评论
Adam Danz
2019-8-31
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?
Adam Danz
2019-8-31
编辑:Adam Danz
2019-8-31
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).
采纳的回答
Walter Roberson
2019-8-31
evalin('base', 'clear VARIABLENAME')
11 个评论
Walter Roberson
2023-4-19
Please see https://www.mathworks.com/help/matlab/matlab_prog/command-vs-function-syntax.html to get more information about why evalin('base', 'clear app.PLUTODropDown.Value') is not going to work.
Walter Roberson
2023-4-19
I would also like to ask you, how can I list in the dropdown the variable that are created within the matlab.app application and not those that are in the base WS?
You will find that in practice most of them should not be eligible for clearing.
更多回答(1 个)
R.G.
2019-8-31
To clear variable use 'clear' function instead, ex:
clear('v')
where 'v' is variable name.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scope Variables and Generate Names 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!