anyway to clear variable in Matlab workspace from app?

70 views (last 30 days)
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 Comments
Adam Danz
Adam Danz on 31 Aug 2019
Edited: Adam Danz on 31 Aug 2019
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).

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 31 Aug 2019
evalin('base', 'clear VARIABLENAME')
  4 Comments
Yu Li
Yu Li on 1 Sep 2019
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

Sign in to comment.

More Answers (1)

R.G.
R.G. on 31 Aug 2019
To clear variable use 'clear' function instead, ex:
clear('v')
where 'v' is variable name.
  3 Comments
Adam Danz
Adam Danz on 31 Aug 2019
Sorry, RG! Not sure how I made that mistake! I fixed my comment.

Sign in to comment.

Categories

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!