Help: Array Double != Array Double ....Why ?

ZeroREA

New member
Joined
Jun 22, 2003
Messages
2
First forgive me if this is not a syntax related problem, but I think it is to special for the General forum and may be related to a syntax or whatever problem.

I have a problem with VB (.NET) arrays and I really do NOT understand it....

I construct an array and give it to a function (Matlab DLL). However the problem is NOT the Matlab DLL !

This works:

Dim data1 As Double()
data1 = New Double(3) {}
data1(1) = 4
data1(2) = 7.5
data1(3) = 2.3


This give me an absolute crash in my function Code since it seems to be different:

Dim myDataArray1() As Double
myDataArray1 = New Double() {}
Dim myDataArray2() As Double
myDataArray2 = New Double() {}
Dim myDataArray3() As Double
myDataArray3 = New Double() {}

ReDim myDataArray1 (100)
ReDim myDataArray2 (100)
ReDim myDataArray3 (100)


For i = 1 To 100
myDataArray1 (i) = i
myDataArray2 (i) = i / 2
myDataArray3 (i) = i / 4
Next i


Both are Double Arrays, so what is the difference between them ???

My Matlab-Function needs an array of double like data1(1) = 4 , but this is not very dynamicly...

Example for my function:

Call myChaosLibrary.poincareplot(myDataArray1, myDataArray2, myDataArray3,....)

If I do this:

Dim myDataArray1 As Double()
myDataArray1 = New Double(3) {}
myDataArray1 (1) = 4
...

and call the function above everything works fine !

But: If I use the other method for dynamic data content the array differs within the DLL... It does not crash really: the content of the arrays differ and produce a wrong result within the DLL. Funny: it seems that witin the DLL we get some kind of myDataArray1 = myDataArray2 = myDataArray3

This is definitly a problem from the VB side and not from Matlab since the Matlab script works fine itself and it works with the "myDataArray1 (1) = 4 " assignement.


I really appreciate any help
 
Strange, but after recompiling the Matlab scripts (this time with debug information) it seems to run. Very strange. Anyway thanks for your fast help try (the i=1 was not the problem)
 
Back
Top