How can I use multiple output arguments from a compiled .NET assembly in Visual Basic?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 21 Mai 2010
Bearbeitet: MathWorks Support Team
am 14 Apr. 2023
I have built a .NET assembly of the following MATLAB function:
function [a,b] = TwoOutputs()
[a, b] = eig([1 2;3 4]);
I would like to retrieve 'a' and 'b' in a Visual Basic project.
Akzeptierte Antwort
MathWorks Support Team
am 13 Apr. 2023
Bearbeitet: MathWorks Support Team
am 14 Apr. 2023
One of the ways of retrieving multiple output arguments in VB, is by collecting the output in an instance of MWArray, and then creating separate instances of MWNumericArray(s), or equivalent types.
The example below shows how to use the two output arguments of the function described above:
Dim myObj As TwoOutputCompClass = New TwoOutputCompClass()
' Invoke the appropriate constructor for MWArray by explicitly specifying the number of output arguments
Dim argsOut() As MWArray = myObj.TwoOutputs(2)
Dim resultArray1 As MWNumericArray = New MWNumericArray(MWArrayComplexity.Real, MWNumericType.Double, argsOut(0).NumberOfElements)
Dim resultArray2 As MWNumericArray = New MWNumericArray(MWArrayComplexity.Real, MWNumericType.Double, argsOut(1).NumberOfElements)
Dim idx As Integer = Nothing
For idx = 1 To argsOut(0).NumberOfElements
resultArray1(idx) = (CType(argsOut(0), MWNumericArray))(idx)
resultArray2(idx) = (CType(argsOut(1), MWNumericArray))(idx)
Next idx
Console.WriteLine("EigVal: {0}", resultArray1)
Console.WriteLine("EigVec: {0}", resultArray2)
For another detailed example, please see the "Spectral Analysis Example" here:
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Deploy to .NET Applications Using MWArray API finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!