<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Clearing the Air</title>
	<atom:link href="http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Loren Shure</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-32945</link>
		<dc:creator>Loren Shure</dc:creator>
		<pubDate>Mon, 30 Jan 2012 16:30:46 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-32945</guid>
		<description>Ravi-

If you look at the documentation, you will see that you can clear individual variables.  But if you want to clear them, you must do so by name.  So this would work for your example.

&lt;pre class=&quot;code&quot;&gt;
varstoclear = {&#039;v1&#039;,&#039;a4&#039;,&#039;a6&#039;};  notice curly braces
clear(varstoclear{:})
&lt;/pre&gt;

That places the names into a cell array, calls clear in functional form by using the comma-separated list feature of cell arrays.  You can learn more about those topics on other posts here and in the user documentation.

--Loren</description>
		<content:encoded><![CDATA[<p>Ravi-</p>
<p>If you look at the documentation, you will see that you can clear individual variables.  But if you want to clear them, you must do so by name.  So this would work for your example.</p>
<pre class="code">
varstoclear = {'v1','a4','a6'};  notice curly braces
clear(varstoclear{:})
</pre>
<p>That places the names into a cell array, calls clear in functional form by using the comma-separated list feature of cell arrays.  You can learn more about those topics on other posts here and in the user documentation.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ravi</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-32944</link>
		<dc:creator>Ravi</dc:creator>
		<pubDate>Mon, 30 Jan 2012 16:03:18 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-32944</guid>
		<description>I was wondering if clear could be  used with a matlab array. By that I mean I would like to call a command like this

varstoclear=[v1,a4,a6]
clear varstoclear


Here v1, a4,a6 are well defined variables. Is it possible to do something like this? I want to do this because I have a whole set of variables that I would want to clear. So instead of giving clear followed by a huge list of arguements, I feel it is cleaner if all the variables to be cleared are kept in an array, and clear is called on this array.</description>
		<content:encoded><![CDATA[<p>I was wondering if clear could be  used with a matlab array. By that I mean I would like to call a command like this</p>
<p>varstoclear=[v1,a4,a6]<br />
clear varstoclear</p>
<p>Here v1, a4,a6 are well defined variables. Is it possible to do something like this? I want to do this because I have a whole set of variables that I would want to clear. So instead of giving clear followed by a huge list of arguements, I feel it is cleaner if all the variables to be cleared are kept in an array, and clear is called on this array.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-31692</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 22 Sep 2010 17:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-31692</guid>
		<description>Sunny,

Check out persistent ( http://www.mathworks.com/help/techdoc/ref/persistent.html ) if the variable you want to save is part of a function workspace.

--Loren</description>
		<content:encoded><![CDATA[<p>Sunny,</p>
<p>Check out persistent ( <a href="http://www.mathworks.com/help/techdoc/ref/persistent.html" rel="nofollow">http://www.mathworks.com/help/techdoc/ref/persistent.html</a> ) if the variable you want to save is part of a function workspace.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sunny R Billava</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-31689</link>
		<dc:creator>Sunny R Billava</dc:creator>
		<pubDate>Wed, 22 Sep 2010 09:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-31689</guid>
		<description>Hi,

If i don&#039;t want a variable getting cleared(deleted) from the workspace, but still it can be updated. Can this be done? ...some sort of locking of the variable.

-Sunny</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>If i don&#8217;t want a variable getting cleared(deleted) from the workspace, but still it can be updated. Can this be done? &#8230;some sort of locking of the variable.</p>
<p>-Sunny</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29917</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 04 Dec 2008 17:13:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29917</guid>
		<description>John-

There are at least 2 ways to get the data to the base workspace besides the load/save method.  First, and highly encouraged, is to return the variables as outputs from the function.  Second possibility, which I prefer less, is to have your function issue some assignin statements to the base workspace and get your function variables to POOF (as Steve Lord says) the data into the base workspace.

--Loren</description>
		<content:encoded><![CDATA[<p>John-</p>
<p>There are at least 2 ways to get the data to the base workspace besides the load/save method.  First, and highly encouraged, is to return the variables as outputs from the function.  Second possibility, which I prefer less, is to have your function issue some assignin statements to the base workspace and get your function variables to POOF (as Steve Lord says) the data into the base workspace.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29916</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 04 Dec 2008 17:00:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29916</guid>
		<description>Jorgen, Loren,

I have tried using Jorgen&#039;s approach, but this approach has also frustrated me because I can&#039;t do it in core memory.  You have to save variables to a file and then back in the root workspace reload them.  This isn&#039;t reasonable if the variables take much memory.  Besides, I don&#039;t like having to type &quot;load foo&quot; every time.  And I don&#039;t like creating unnecessary .mat files.  Isn&#039;t there any way to simply set the variables from a function directly into Matlab&#039;s root workspace?

Thanks, John</description>
		<content:encoded><![CDATA[<p>Jorgen, Loren,</p>
<p>I have tried using Jorgen&#8217;s approach, but this approach has also frustrated me because I can&#8217;t do it in core memory.  You have to save variables to a file and then back in the root workspace reload them.  This isn&#8217;t reasonable if the variables take much memory.  Besides, I don&#8217;t like having to type &#8220;load foo&#8221; every time.  And I don&#8217;t like creating unnecessary .mat files.  Isn&#8217;t there any way to simply set the variables from a function directly into Matlab&#8217;s root workspace?</p>
<p>Thanks, John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29527</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 19 Jun 2008 19:20:50 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29527</guid>
		<description>Vittorio-

What exactly do you mean about using clear in batch and it not working?

clear should clear the memory from MATLAB, enabling MATLAB to use that memory again, if required.  I believe the memory does not get returned to the operating system until you quit MATLAB because of how the underlying memory managers work.  It behaves differently on Windows.

--Loren</description>
		<content:encoded><![CDATA[<p>Vittorio-</p>
<p>What exactly do you mean about using clear in batch and it not working?</p>
<p>clear should clear the memory from MATLAB, enabling MATLAB to use that memory again, if required.  I believe the memory does not get returned to the operating system until you quit MATLAB because of how the underlying memory managers work.  It behaves differently on Windows.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vittorio</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29526</link>
		<dc:creator>Vittorio</dc:creator>
		<pubDate>Thu, 19 Jun 2008 16:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29526</guid>
		<description>Loren,
in Solaris environment (and I suspect in Linux too), in batch execution the statement clear does not work. Is there a turnaround to free memory in Unix from a matlab script?

regards</description>
		<content:encoded><![CDATA[<p>Loren,<br />
in Solaris environment (and I suspect in Linux too), in batch execution the statement clear does not work. Is there a turnaround to free memory in Unix from a matlab script?</p>
<p>regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jorgen Harmse</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29343</link>
		<dc:creator>Jorgen Harmse</dc:creator>
		<pubDate>Thu, 29 May 2008 14:56:51 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29343</guid>
		<description>I don&#039;t quite see what Neill &amp; Robert are trying to do. If I want a &#039;clean slate&#039;, I write a function, unless I also need to recover memory. The variables created in the function can even be returned.

function S = foo

% Perform calculations, etc.

% Remove loop control variables and other clutter,
% perhaps with clearvars -except.

save fooTemp.mat;
S = load(&#039;fooTemp.mat&#039;);
delete fooTemp.mat;
% There might be a clean way to do this in core memory,
% but the only way I know involves repeated eval calls.
return;</description>
		<content:encoded><![CDATA[<p>I don&#8217;t quite see what Neill &amp; Robert are trying to do. If I want a &#8216;clean slate&#8217;, I write a function, unless I also need to recover memory. The variables created in the function can even be returned.</p>
<p>function S = foo</p>
<p>% Perform calculations, etc.</p>
<p>% Remove loop control variables and other clutter,<br />
% perhaps with clearvars -except.</p>
<p>save fooTemp.mat;<br />
S = load(&#8216;fooTemp.mat&#8217;);<br />
delete fooTemp.mat;<br />
% There might be a clean way to do this in core memory,<br />
% but the only way I know involves repeated eval calls.<br />
return;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29176</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 20 May 2008 13:19:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/04/08/clearing-the-air/#comment-29176</guid>
		<description>Jon-

I will put the request in and you can too:

http://www.mathworks.com/support/service_requests/contact_support.do

--Loren</description>
		<content:encoded><![CDATA[<p>Jon-</p>
<p>I will put the request in and you can too:</p>
<p><a href="http://www.mathworks.com/support/service_requests/contact_support.do" rel="nofollow">http://www.mathworks.com/support/service_requests/contact_support.do</a></p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
</channel>
</rss>

