By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,721 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

mlabwrap error "Subscript indices must be either real positive integers or logicals"

P: 5
Hi all,

I am using the mlabwrap module in python for my thesis and I have encountered an error : some times when I call my matlab function from my python code it stops and shows this error " mlabrap.error: Subscript indices must be either real positive integers or logicals" and the line where this error occured:"l=mlab.tetris_learn(summ[2:442])" The funny thing is that this error occurs sometimes after this line was executed with no problem before.In other words,when my main python code is executed for a number of iterations,this error occurs either in the second or third iteration.Any ideas,
Thanks in advance,

steve
Jun 15 '10 #1
Share this Question
Share on Google+
7 Replies


Expert 100+
P: 391
Impossible to say without knowing more. Presumably summ[2:422] changes from being a real positive integer or logical to something else?

A handy debugging technique that I use is printing out the relevant variables separately in the line before the bug occurs. So in this case printing summ[2:422] just before the line you've giving.
Jun 16 '10 #2

P: 5
Hi Glenton,thanks for answering.Here is the strangeness of this error,I already am printing summ[2:422] before the error occurs and it displays an array filled with numbers with no gaps or zeros.And the dimensions of this array are correct for my matlab script((1,440) is the dimension).Any ideas??

Steve
Jun 16 '10 #3

Expert 100+
P: 391
Hard to say. Sounds like it might be a problem with running the matlab script twice? Fraid I really don't know...
Jun 16 '10 #4

P: 5
A,ok,many thanks.I will google even more then.Bye,
steve
Jun 16 '10 #5

P: 5
Hi all ,one question :has anyone encountered any indexing problems while using mlabwrap for calling matlab functions from within python??And particularly an error saying :"Subscript indices must be either real positive integers or logicals"

If anyone knows pleeeeeeeeease tell me so OK??

Thanks in advance,
steve
Jun 19 '10 #6

bvdet
Expert Mod 2.5K+
P: 2,851
One thing you could do to narrow the problem down - Encapsulate the block of code causing the problem in a try/except block as in
Expand|Select|Wrap|Line Numbers
  1. try:
  2.     ...code...
  3. except mlabrap.error, e:
  4.     print e
  5.     ...print the values of current variables...
You could also use the debug tool that comes with many IDE's to step through the code.
Jun 20 '10 #7

P: 5
A,ok thanks mate!I will give it a try...Also,I didn't mention that this error occurs after a random time,in other words I don't know when it will occur during my runs,it even doesn't occur at all sometimes .Was that a bit more helpful??Anyways,thanks again,

Steve
Jun 22 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.