Invalid Callee when using Matlab as a COM server
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hello yall! I am trying to use matlab as a com server and I am getting the following error when using GetWorkspaceData()
Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))
here is the code I am using
compiling with MS VStudio 2010 Professional, .NET 3.5
Private Sub RunAsServer() Matlab = New MLApp.MLApp Matlab.MaximizeCommandWindow() Matlab.Execute("cd c:\matlab") Matlab.Execute("a = 23;")
Dim thevar As Object = vbNull Try Matlab.GetWorkspaceData("a", "base", thevar) TextBoxBuffer.Text += thevar.ToString Catch ex As Exception MessageBox.Show(ex.Message) End Try
end Sub
1 comentario
Janis Stolzenwald
el 10 de Feb. de 2019
Editada: Janis Stolzenwald
el 10 de Feb. de 2019
Wow, this question remained unanswered for 7yrs now. "MATLAB Answers" should be called "MATLAB solve it yourself please".
Same problem here. When calling matlab code in a c# loup it crashes after the first iteration with the error message above.
Respuestas (2)
Janis Stolzenwald
el 10 de Feb. de 2019
I solved the problem in my case. Make sure to set the out variable back to null before passing it to Feval again.
0 comentarios
Andy
el 21 de Abr. de 2024
Yeah, interesting @Janis Stolzenwald! Stumbled across the same problem ... thanks for sharing your solution 7 years later!
Did you manage to find also how to do *.Feval on function within function ... such as:
> t2.GetType()
[System.Double[,]]
> object results = null; matlab.Feval("cov", 1, out results, t2)
> results
object[1] { double[10, 10] { { 32.2, -34.599999999999994, 71.65, 1856.1999999999998, 94.25, 35.45, 92.2, 152.3, -138.3, 157 }, { -34.599999999999994, 2939.7999999999993, 2205.55, 18073.399999999998, -40.24999999999994, 261.15000000000003, 2120.3999999999996, 69.10000000000008, 1741.9, 3924 }, { 71.65, 2205.55, 3813.3, 15569.649999999998, 728.5, 39.14999999999998, 3730.3999999999996, 1317.1, 1380.65, 6561.5 }, { 1856.1999999999998, 18073.399999999998, 15569.649999999998, 395910.19999999995, 7004.25, 6084.450000000001, 17791.2, 13353.3, -6674.299999999999, 34322 }, { 94.25, -40.24999999999994, 728.5, 7004.25, 432.5, 61.750000000000014, 788, 729.5000000000001, -400.75, 1367.5 }, { 35.45, 261.15000000000003, 39.14999999999998, 6084.450000000001, 61.750000000000014, 123.2, 79.19999999999999, 119.8, -135.04999999999998, 189.5 }, { 92.2, 2120.3999999999996, 3730.3999999999996, 17791.2, 788, 79.19999999999999, 3677.2, 1419.8000000000002, 1159.2, 6482 }, { 152.3, 69.10000000000008, 1317.1, 13353.3, 729.5000000000001, ...
> object results = null; matlab.Feval("cov(cov)", 1, out results, t2)
System.Runtime.InteropServices.COMException: Undefined function 'cov(cov)' for input arguments of type 'double'.
+ System.RuntimeType.ForwardCallToInvokeMember(string, System.Reflection.BindingFlags, object, object[], bool[], int[], System.Type[], System.Type)
+ MLApp.MLAppClass.Feval(string, int, out object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object)
>
did not expect the above to work, but not sure it's possible to compute "cov(cov(t2))" ... or any other combination of function of a function of a variable ... any ideas?
0 comentarios
Ver también
Categorías
Más información sobre Write COM Applications to Work with MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!