From: Brian <brian1.thomas@ge.com>
Path: news.mathworks.com!newsfeed-00.mathworks.com!webcrossing
Newsgroups: comp.soft-sys.matlab
Subject: Re: decrease in speed due to appending a row vector
Message-ID: <ef580c1.1@webcrossing.raydaftYaTP>
Date: Thu, 24 May 2007 20:20:24 -0400
References: <ef580c1.-1@webcrossing.raydaftYaTP>
Lines: 28
NNTP-Posting-Host: 65.200.157.177
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Xref: news.mathworks.com comp.soft-sys.matlab:410967



I don't know how big will the vector grow each time. The space
depends on the input data which will change most of the time and I
have no way of know the final size.

Joseph wrote:
>
>
> pre-allocate the space for your vector
>
> help zeros
>
> Brian wrote:
>>
>>
>> I have a row vector and I am adding new data elements in
between
> at
>> different locations. The approach i take is copy the vector in
a
>> temporary variable, add the new element at the desired location
> and
>> then append the remaining elements from the temporary variable.
I
>> believed it should be very fast in Matlab but if i repeat it
> 15000
>> times it takes me 10 seconds which is very slow for my
> application.
>> Is there any other way to get around this problem.