Path: news.mathworks.com!not-for-mail
From: "Wu" <hanwufu@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Memory problems
Date: Sun, 9 Nov 2008 11:38:02 +0000 (UTC)
Organization: Nat Taiwan Univ
Lines: 12
Message-ID: <gf6i2q$1oj$1@fred.mathworks.com>
References: <12408444.1226087385326.JavaMail.jakarta@nitrogen.mathforum.org> <i3kRk.169$M_1.58@newsfe01.iad>
Reply-To: "Wu" <hanwufu@hotmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1226230682 1811 172.30.248.37 (9 Nov 2008 11:38:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 9 Nov 2008 11:38:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1002314
Xref: news.mathworks.com comp.soft-sys.matlab:499735


Walter is right when i says: use logical indexing.

never copy big variables/objects so they are in a good shape. Theses steps are good in order to understand what you want to do. It is not efficient to have the information twice in your memory. 

A general hint:

 use the "whos" at certain steps in yout function to check if there are variables you will not need anymore. After identifying these variables "clear" them. If you need these big variables later, then "save" and "clear" to "load" them later.