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.

 채택된 답변

Steven Feingold
Steven Feingold 2014년 7월 1일

0 개 추천

Ok, I figured it out myself. For some reason the Visual basic only passes the first entry of each vector to the DLL, but in Matlab the entire vector needs to be passed.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by