|
On May 6, 8:56 am, kamekame <nanosec...@web.de> wrote:
> If i dont use preallocation i get this:
>
> ??? Undefined function or method 'B' for input arguments of type 'double'=
.
> Error in ==> projekt008_SPULE at 67
> B(x,y,z,1) = B(x,y,z,1) + dB(1);
>
> What should I do?
>
> I need 4-D because I want the x-, y- and z-component of dB. dB is the inf=
initesimal magnetic field.
You don't understand about addresses in arrays.
They are integers representing the position relative to the start, not
the numbers themselves.
So, for your array B the first column is addressed like this: B
(1,1,1,1), B(2,1,1,1), B(3,1,1,1) .. up to B(10,1,1,1).
Now, what those correspond to in terms of your x is entirely up to
you.
You say x goes from -5 to 5.
This means you need 11 rows (not 10).
B(1,1,1,1) is for x=-5
B(2,1,1,1) is for x=-4
B(3,1,1,1) is for x=-3
B(4,1,1,1) is for x=-2
B(5,1,1,1) is for x=-1
B(6,1,1,1) is for x=0
B(7,1,1,1) is for x=1
B(8,1,1,1) is for x=2
B(9,1,1,1) is for x=3
B(10,1,1,1) is for x=4
B(11,1,1,1) is for x=5
|