Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University 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  
Amadeus

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

Hello,

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

Regards

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

interp=1;

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

vector(2*i-1,:,:)=vector(i,:,:);

end

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;

end

tracks(1,k).matrix = vector;

end

end



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.