Prev: undo-ing wrong entry when using 'input' function
Next: how to design two bandpass filter , after same gaussian noise pass throuht those two filter, output gaussian noise have same energy
From: Aaron Robinson on 23 Jul 2010 13:21 I am trying to create a method for accessing a C# API from matlab. Currently, I am trying to solve the problem by creating a COM server as described by this post: http://www.mathworks.com/matlabcentral/fileexchange/16549-using-c-functions-and-forms-in-matlab Everything "seems" to work nice except for calling this C# function: bool GetSpectrum(int spectraID, int scanNum, ref double[] mz, ref float[] intensities); In order to give C# the proper pointers for this operation, I have tried a number of solutions. 1st attempt: mzArray = double(zeros(100, 1)); intensityArray = single(zeros(100, 1)); feature('COM_PassSafeArrayByRef', 1); feature('COM_SafeArraySingleDim', 1); ScanNum = 1; bool = reader.GetSpectrum_2(1, ScanNum, mzArray, intensityArray); Result: This will execute but once the method has returned, it has not changed the Arrays which should be getting resized and populated. 2nd attempt: mzArray = libpointer('doublePtr', double(zeros(1000, 1))); intensityArray = libpointer('singlePtr', single(zeros(1000, 1))); feature('COM_SafeArraySingleDim', 1); bool = reader.GetSpectrum_2(1, ScanNum, mzArray, intensityArray); Result: This will cause a segmentation violation. I have a few other ways but everything else error ed out at the GetSpectrum_2 call because of invalid arguments. This leads me to believe that the 2nd attempt is on the right track but I am still having memory management problems. The arrays which are being returned should have between (1000-10000) values. My Configuration: MATLAB Version: 7.10.0.499 (R2010a) MATLAB License: 208967 Operating System: Microsoft Windows XP Window System: Version 5.1 (Build 2600: Service Pack 3) Processor ID: x86 Family 15 Model 4 Stepping 3, GenuineIntel Virtual Machine: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode Default Encoding: windows-1252 I have the rest of the crash dump if anyone is interested. Thanks, -Aaron |