Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Preallocation help needed
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  

Posts: 9
Registered: 10/8/12
Preallocation help needed
Posted: Dec 10, 2012 3:39 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I could not find out how to properly do the preallocation for the following situation. Could you please give me a hand?


Size of tracks' changes every loop, so I want to do preallocation for it but could not figure out how. (Size of tracks(1,i).nPoints remains same. Only tracks(1,i).matrix changes, 1?i?max_n_trks)

%% Interpolation


for param=1:interp

for k=1:max_n_trks % maximum number of tracks

vector = tracks(1,k).matrix;
len = tracks(1,k).nPoints;

for i=len:-1:1



tracks(1,k).nPoints = (tracks(1,k).nPoints*2)-1;
len = tracks(1,k).nPoints;

for i=1:2:len-1

vector(i+1,:,:) = (vector(i,:,:) + vector(i+2,:,:))/2;


tracks(1,k).matrix = vector;



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2016. All Rights Reserved.