Path: news.mathworks.com!not-for-mail
From: "Daphne W" <daphnew_too_nospam@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to insert/delete rows in a matrix without copy the rest of matrix
Date: Wed, 25 Jul 2007 15:03:46 +0000 (UTC)
Organization: Technion
Lines: 38
Message-ID: <f87ooi$rma$1@fred.mathworks.com>
References: <f87kg3$9ri$1@fred.mathworks.com>
Reply-To: "Daphne W" <daphnew_too_nospam@yahoo.com>
NNTP-Posting-Host: webapp-00-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1185375826 28362 172.30.248.35 (25 Jul 2007 15:03:46 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 25 Jul 2007 15:03:46 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1066798
Xref: news.mathworks.com comp.soft-sys.matlab:421000




The speed of the calculation partially depends on the system you're workin on. 
On my laptop got 
Elapsed time is 0.415618 seconds.
Elapsed time is 0.415288 seconds.
For your code.

Trying to do this faster, I simply redefined the a matrix without the first column as you have: 

a=rand(5000);
tic; a=a(:,2:end); toc
Elapsed time is 0.250436 seconds.
Not great, but a bit better. 

Daphne



"Chenyang " <john.doe.nospam@mathworks.com> wrote in 
message <f87kg3$9ri$1@fred.mathworks.com>...
> Matlab is very slow add/delete a row in a matrix.
> It always trying to copy the whole matrix
> e.g., 
> 
> a = rand(5000);
> tic
> a(:,1) = [];
> toc
> tic
> a = [a(:,1),a];
> toc
> Elapsed time is 0.447241 seconds.
> Elapsed time is 0.556416 seconds.
> 
> I need to insert/delete a row into a large matrix.
> How to make it fast?
>