A bug with vector lengths?
Show older comments
Hey everyone.
Without going into too much unnecessary detail, I'll try and explain this strange problem I'm having.
I've been writing some optimization code, in which I have a set of starting values (importantly, containing a value N which specifies vector length), which are repeatedly adjusted and rated for suitability using an objective function. All of this takes place in a loop.
The objective function always (purposely) outputs a vector of N+1 values, which is then used as the standard length for the rest of what I'm doing in the loop.
This all usually works absolutely fine, but recently I have come across a set of values where N doesn't increase to N+1 as it usually should, and hence it causes errors in the rest of the code. This set of values is nothing out of the ordinary, and furthermore, when I break the code down and run it in sections with these values, N increases to N+1 as it should - so the error only happens while running in a loop.
Therefore, there doesn't seem to be any problem with my code - so I'm just wondering if anyone has experienced something similar or knows of any bugs that produce this behaviour in Matlab?
Hope that wasn't too complicated. Thanks in advance if you have any advice!
6 Comments
Oleg Komarov
on 26 Jul 2012
I am afraid that without a snippet that reproduces the issue it's gonna be hard to give some feedback.
What if I told you that "while driving on a road I suddenly crushed my car but usually it doesn't happen, would you happen to know what might have caused it?"
C Meek
on 26 Jul 2012
per isakson
on 27 Jul 2012
- Is there an error message?
- Does it happens in a static workspace?
C Meek
on 27 Jul 2012
Tom
on 27 Jul 2012
have you set it to go into debug mode when the error occurs? Write
dbstop if error
C Meek
on 27 Jul 2012
Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!