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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tallman
    New Member
    • Jun 2010
    • 5

    #1

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

    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(s umm[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
  • Glenton
    Recognized Expert Contributor
    • Nov 2008
    • 391

    #2
    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.

    Comment

    • tallman
      New Member
      • Jun 2010
      • 5

      #3
      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

      Comment

      • Glenton
        Recognized Expert Contributor
        • Nov 2008
        • 391

        #4
        Hard to say. Sounds like it might be a problem with running the matlab script twice? Fraid I really don't know...

        Comment

        • tallman
          New Member
          • Jun 2010
          • 5

          #5
          A,ok,many thanks.I will google even more then.Bye,
          steve

          Comment

          • tallman
            New Member
            • Jun 2010
            • 5

            #6
            mlabwrap error :

            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

            Comment

            • bvdet
              Recognized Expert Specialist
              • Oct 2006
              • 2851

              #7
              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
              Code:
              try:
                  ...code...
              except mlabrap.error, e:
                  print e
                  ...print the values of current variables...
              You could also use the debug tool that comes with many IDE's to step through the code.

              Comment

              • tallman
                New Member
                • Jun 2010
                • 5

                #8
                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??Anyway s,thanks again,

                Steve

                Comment

                Working...