Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB error when storing values in a matrix

  1. Apr 2, 2012 #1
    Basically I have a function file set up called BSform.m, I'm confident this has nothing to do with my problem

    My problem is this driver file for the function

    for i = 0:0.01:1

    My output Y ALWAYS gives me a 1x2 vector (this is what I want, the function is working as intended)

    I am trying to STORE this vector in my X matrix

    Everything is FINE up until i get to i=0.14, and I've no idea why

    The error I get is:

    ??? Attempted to access X(15,1); index must be a positive integer or logical.

    Error in ==> File2 at 5

    It's really weird since if I manually input this Y value it manages to access it fine and store it in X. I thought about overriding it and moving on, but then it screwed up when it hit X(29,1) and again at X(30,1) then again a few steps more, really irregular pattern.

    Any idea what's causing this? I've tried transposing it all, and the same problem hits at the same values for i.

  2. jcsd
  3. Apr 3, 2012 #2
    Why don't you convert index to integer, e.g.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook