Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matlab to Excel issue
Date: Tue, 25 Sep 2007 00:52:17 +0000 (UTC)
Organization: TACT Computer Systems Ltd
Lines: 39
Message-ID: <fd9m41$68t$1@fred.mathworks.com>
References: <fd9i2n$adu$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1190681537 6429 172.30.248.37 (25 Sep 2007 00:52:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 25 Sep 2007 00:52:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 642467
Xref: news.mathworks.com comp.soft-sys.matlab:430019



> The issue is this.  When I run my code, the program takes a 
> while to process everything.  And usually the matrices that 
> I work with in MatLab are on the order of [384x7] in size.  
> I feel that this is an Excel memory-related issue.  

xlswrite is very inefficient, in that it does not reuse
existing open XLS server COM connections - it reopens a new
connection with each invocation. This takes a lot of time
and system memory, especially if you run the command in a
loop. I suggest you use xlswrite1 or officedoc, both on the
File Exchange, which reuse open connections. There are a few
other alternatives on the FEX - search around.

> Everytime I run my program and it stops due to the above 
> error, I check the task manager and there are several (>30) 
> instances of EXCEL.EXE*32's running each taking up ~20,000K 
> of space in Mem Usage.
> 
> Does anybody know what is causing this?  And if so, how to 
> remedy it?

xlswrite crashed without bothering to close the open COM
connections... You have no access to these connections and
must delete them via the Task Manager.

> One thing that I tried to do was use the following:
> 
> Excel = activexsrv('Excel.Application') to start up an 
> activexsrv for Excel, and use Excel.Quit at the end of the 
> code so that I do not have recurring instances of Excel 
> open in the Task Manager.  Is this the correct way to go 
> about it?

Yes. You can edit/type xlswrite or xlswrite1 to get started,
or simply use one of the aforementioned FEX submissions.

Yair Altman
http://ymasoftware.com