Discussion:
'clear all' doesn't clear certain variables
(too old to reply)
nodal
2006-06-05 17:46:19 UTC
Permalink
does any one ever encountered this problem? when i include 'clear
all' in my script(.m file) MATLAB is not clearing the variables
created by "assignin" command(it clears other variable though).
However, it clears everything when i type 'clear all' in command
window.

Any ideas why this is happening?

Thanks
Nodal.
Jeremy Smith
2006-06-05 20:49:49 UTC
Permalink
It sounds like you're using functions. In that case everything you
do within your function stays within that function's workspace.
'assignin' sends the variable from the function to either the calling
function or the base workspace. When you call 'clear all' you are
only clearing the variables within the function workspace.

Look up the 'evalin' function.
Nodal DOF
2006-06-07 20:46:31 UTC
Permalink
Thanks for your reply. You are correct. I am using functions. I still
dont understand how to clear the base workspace from within the
function. The problem is even if i use the 'caller' as assignin ws
option, i cant clear the varibles as the variable are stored in
another functions scope. Any suggestions how to clear the base
workspace from with in the function?

Thanks
NodalDOF.
Post by Jeremy Smith
It sounds like you're using functions. In that case everything you
do within your function stays within that function's workspace.
'assignin' sends the variable from the function to either the
calling
function or the base workspace. When you call 'clear all' you are
only clearing the variables within the function workspace.
Look up the 'evalin' function.
Doug Schwarz
2006-06-08 00:12:26 UTC
Permalink
Post by Nodal DOF
Thanks for your reply. You are correct. I am using functions. I still
dont understand how to clear the base workspace from within the
function. The problem is even if i use the 'caller' as assignin ws
option, i cant clear the varibles as the variable are stored in
another functions scope. Any suggestions how to clear the base
workspace from with in the function?
Yes, you need the evalin function:

evalin('base','clear all')
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
nodal dof
2006-06-08 03:07:29 UTC
Permalink
Thank you! That works.
Post by Doug Schwarz
evalin('base','clear all')
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
Continue reading on narkive:
Loading...