Retrieving array from calllib
Mostra commenti meno recenti
I have a DLL that I'm trying to use in Matlab, and I'm basing my code off a successful call of the DLL that I have in Excel using Visual Basic. In Visual Basic the code to call the DLL looks like this:
Call CurveFitFunc(x(1), y(1), nr, results(1), initParams(1))
Where 'x' and 'y' are vectors that a curve is being fit to, 'nr' is the length of the vector, 'results' and 'initParams' are vectors containing only zeros (lengths 5 and 4 respectively). When called in Visual Basic, the function updates the entries in 'results' and 'initParams' with the values that I want.
I've been able to load and run the dll in Matlab, but rather than updating the input vectors, Matlab outputs only single values to new variables. Is this an issue with pointers, or something that Matlab can't do?
Here is the Visual Basic declaration:
Public Declare Sub CurveFitFunc Lib "C:\Excel Add-ins\...\DLLNAME.dll" (xValues As Double, yValues As Double, ByVal xlen As Long, results As Double, initParams As Double)
And here is the header file that I'm using for Matlab:
void _stdcall CurveFitFunc(double *xValue, double *yValue, int xlen, double *results, double *initParams);
Finally, here is the result from libfunctionsview:
[doublePtr, doublePtr, doublePtr, doublePtr] CurveFitFunc (doublePtr, doublePtr, int32, doublePtr, doublePtr)
I've never called DLLs before, so anything that might point me in the right direction is helpful.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su C Shared Library Integration in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!