<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243512</link>
    <title>MATLAB Central Newsreader - How to clear all variables except one or two</title>
    <description>Feed for thread: How to clear all variables except one or two</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 31 Jan 2009 23:40:17 -0500</pubDate>
      <title>How to clear all variables except one or two</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243512#625229</link>
      <author>Diego Zegarra</author>
      <description>I have a code that creates many variables and at each iteration I want to clear all the variables except for one or two. Is this possible without specifying clear A, clear B and so on for every variable?&lt;br&gt;
&lt;br&gt;
I know clear all deletes them all but I need to keep one of them.&lt;br&gt;
&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Sun, 01 Feb 2009 00:11:01 -0500</pubDate>
      <title>Re: How to clear all variables except one or two</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243512#625230</link>
      <author>Matt Fig</author>
      <description>Do a search on the FEX for:  keep&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Ak6&amp;lt;k]eihkh*aca{dIppd#ldkak]lijq{{]u_kj]{{]{_^r]gp]U#e{{^qa</description>
    </item>
    <item>
      <pubDate>Sun, 01 Feb 2009 00:37:01 -0500</pubDate>
      <title>Re: How to clear all variables except one or two</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243512#625231</link>
      <author>Diego Zegarra</author>
      <description>Actually I found a way that can be done easily, this for anyone out there needing this info,&lt;br&gt;
&lt;br&gt;
clearvars -except v1 v2 ... clears all variables except for those specified following the -except flag. Use the wildcard character '*' in a variable name to exclude variables that match a pattern from being cleared. clearvars -except X* clears all the variables in the current workspace, except for those that start with X, for instance.</description>
    </item>
    <item>
      <pubDate>Sun, 01 Feb 2009 00:51:02 -0500</pubDate>
      <title>Re: How to clear all variables except one or two</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243512#625232</link>
      <author>Matt Fig</author>
      <description>What version are you using?  I don't have a clearvars command.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
k{{_l{A{ueUpah6]ajhdjdqie{kk#^]qcga{p^#*{]{k]airIp]dkk_]&amp;lt;]l</description>
    </item>
    <item>
      <pubDate>Sun, 01 Feb 2009 01:23:02 -0500</pubDate>
      <title>Re: How to clear all variables except one or two</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243512#625233</link>
      <author>Diego Zegarra</author>
      <description>R2008a, I think it just came out starting this version.</description>
    </item>
    <item>
      <pubDate>Sun, 01 Feb 2009 22:57:01 -0500</pubDate>
      <title>Re: How to clear all variables except one or two</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243512#625330</link>
      <author>Jan Simon</author>
      <description>Dear Diego Zegarra!&quot;&lt;br&gt;
&lt;br&gt;
&amp;gt; I have a code that creates many variables and at each iteration I want to clear all the variables except for one or two. Is this possible without specifying clear A, clear B and so on for every variable?&lt;br&gt;
&lt;br&gt;
Let the names of all variables, which should be cleared, start with a specific string, e.g.&lt;br&gt;
&quot;away_&quot;. Then &quot;clear away_*&quot; deletes them from memory.&lt;br&gt;
&lt;br&gt;
By the way: clearing and recreation of variables is very time consuming. It could be more effective to use a cell instead of a cloud of variables.&lt;br&gt;
&lt;br&gt;
Good luck, Jan Simon</description>
    </item>
    <item>
      <pubDate>Mon, 02 Feb 2009 15:49:53 -0500</pubDate>
      <title>Re: How to clear all variables except one or two</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243512#625462</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Diego Zegarra&quot; &amp;lt;diegozbb@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:gm2thm$mcb$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; R2008a, I think it just came out starting this version.&lt;br&gt;
&lt;br&gt;
You're correct, CLEARVARS was introduced in release R2008a.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/rn/brjk1q5-1.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/rn/brjk1q5-1.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
  </channel>
</rss>

