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: Insert row in an array and delete last row
Replies: 7   Last Post: Jan 21, 2013 2:38 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Michael Doukas

Posts: 12
Registered: 12/26/12
Re: Insert row in an array and delete last row
Posted: Jan 20, 2013 12:11 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Michael Doukas" wrote in message <kdh748$a5g$1@newscl01ah.mathworks.com>...
> I have the following code (it is for a Tabu search algorithm):
> 1: InitialSol=generator;
> 2: lsol=size(InitialSol,2);
> 3: List=zeros(l,lsol);
> 4: i=0;
> 5:
> 6: while i<=l
> 7: % tweak the initial sol
> 8: Sol=tweak(InitialSol);
> 9: % check if tweaked child already exists in the tabu list
> 10: if ismember(Sol,List)==0
> 11: % if it does not exist add it in the list
> 12: List=circshift(List,1);
> 13: List(i,:)=Sol;
> 14: i=i+1;
> 15: end
> 16: end
> But it reaches line 13 and throws:
> Subscript indices must either be real positive integers or logicals.
> Error in ts (line 40)
> List(i,:)=Sol;

I checked the loop and apparently it reaches i=2 and after that i is not increasing.
It just creates new Sol without checking if the Sol if in the List.
Therefore, it never exists the loop.

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

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.