[VB.NET] [MWArray] Can't cast MWNumericArray to MWCellArray
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm currently working on a project to reroute an existing .NET tool from an 'old' DLL-deploy to the .NET DLL-deploy. So far, so good. I am calling the DLL and it initializes. However, it seems you need to feed the newer DLL-type with the MWArray data-types. I am using a 2011a DLL in 32-bits.
So I switched from the old 'Object-type' to designated MWArrays. I have 5 arrays, 4 of which are exclusively numeric in the data it needs to hold. The fifth, has a small problem, because it will have to contain string-types and numerics (doubles). For this, I have read I need to use the MWCellArray, but it does not work, and I keep getting the following error message;
Unable to cast object of type 'MathWorks.MATLAB.NET.Arrays.MWNumericArray' to type 'MathWorks.MATLAB.NET.Arrays.MWCellArray
This is the calling code;
Dim dr As DataRow
For rowIndex As Integer = 0 To dTable.Rows.Count - 1
dr = dTable.Rows(rowIndex)
newArray(rowIndex, 0) = CDbl(dr(0))
For columnIndex As Integer = startkolom + 1 To dTable.Columns.Count - 1
If dr(columnIndex) Is Nothing OrElse _
IsDBNull(dr(columnIndex)) OrElse _
dr(columnIndex).ToString.Length = 0 OrElse _
dr(columnIndex).ToString = "#N/A" Then
newArray(rowIndex, columnIndex - startkolom) = Double.NaN
Else
If IsNumeric(dr(columnIndex)) Then
newArray(rowIndex, columnIndex - startkolom) = CDbl(dr(columnIndex))
Else
newArray(rowIndex, columnIndex - startkolom) = dr(columnIndex)
End If
End If
Next
Next
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Deploy to .NET Applications Using MWArray API dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!