I am trying to run this:
for lambda = 0:0.1:0.6
N(i,1) = lambda;
N(i,2) = Picard(lambda);
But the output is:
??? Attempted to access N(7,1); index must be a positive integer or logical.
I think is just a problem of precision: index of a matrix should be integer numbers.
You could replace the 3rd et 4th line by:
On Feb 4, 7:20 am, “Lars ”
> Surely i=10*lambda+1 should already be an integer vor lambda=0:0.1:x ?
> Or does Matlab produces non-integers with that?
No, I’m afraid not. The problem is that 0.1 can’t be represented exactly in the binary floating point arithmetic system used by
Perhaps the following example will help- suppose that you have a calculator that stores numbers in 12 digit decimal floating point
form (this is actually quite common), and you want to multiply 3* (1/3). In the calculator, you’d get
so 3*(1/3) wouldn’t be exactly 1.
The same thing is happening in binary floating point when you multiply 7*0.1 in MATLAB.
If you want a closer look at what number you do get, use the MATLAB command:
to set the display precision to fifteen digits, and then multiply out 7*0.1.