Path: news.mathworks.com!not-for-mail
From: "Ashish Uthama" <first.last@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Clear Empty Variables in Workspace
Date: Mon, 23 Mar 2009 11:48:30 -0400
Organization: TMW
Lines: 28
Message-ID: <op.uq84u4sba5ziv5@uthamaa.dhcp.mathworks.com>
References: <gq04ot$it3$1@fred.mathworks.com>
NNTP-Posting-Host: uthamaa.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1237823310 10706 172.31.57.126 (23 Mar 2009 15:48:30 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 23 Mar 2009 15:48:30 +0000 (UTC)
User-Agent: Opera Mail/9.63 (Win32)
Xref: news.mathworks.com comp.soft-sys.matlab:526986


On Fri, 20 Mar 2009 09:13:01 -0400, Eric   
<edette1remove.this1rman@comcast.net> wrote:

> This is probably a trivial question but.........I am working on a  
> project that queries a SQL database and if there are no records found  
> for the query, it returns an empty record set & Matlab creates an empty  
> cell array.

Why not check the return value and clear it if it matches your conditions?

>
> Does anyone have a script to loop through the variables in the workspace  
> & clear the ones that meet a certain criteria?
>
> I need to remove variables that meet the criteria below:
> 1) max value in array is zero
> 2) all cells are empty
>
> Thanks,
> Eric

If you _have_ to do this, you might want to look at
WHO   - to get a list of your workspace variables
EVAL  - to run your conditions on the variable names
CLEAR - ...

EVAL is a 'no-no' in CSSSM, but I cant think of another way.
I would suggest trying something along the lines of my suggestion above.