Basically I have a function file set up called BSform.m, I'm confident this has nothing to do with my problem(adsbygoogle = window.adsbygoogle || []).push({});

My problem is this driver file for the function

X=zeros(101,2);

for i = 0:0.01:1

[C1,P1]=BSform(200,200,2,0,0.02,i);

Y=[C1,P1]

X(100*i+1,1)=Y(1,1)

X(100*i+1,2)=Y(1,2)

end

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

X(100*i+1,1)=Y(1,1)

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.

Thanks

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

**Physics Forums | Science Articles, Homework Help, Discussion**