NET-matlab hybrid environment
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Andrey
el 4 de Dic. de 2022
Respondida: Aniket
el 19 de Sept. de 2024
Good afternoon,
Version 2022b finally has normal integration with .NET applications.
Many thanks to the MathWorks team.
My C# program receives online data from an external device, and then I transfer this data to Matlab for processing.
I would like to transfer only a new portion of information to Matlab and not transfer it in full each time as function arguments.
In previous versions (until 2022a) when using COM server, it was possible to send a variable to matlab using the function
matlab.PutWorkspaceData("var_", "base", var_);
How now to carry out such a transfer?
I would appreciate some helpful advice on how to organize such an environment more efficiently.
1 comentario
chrisw23
el 6 de Dic. de 2022
How about instanciating your C# app from Matlab and register for data transfer events (addlistener) provided by the C# app (delegates/events).
Respuesta aceptada
Aniket
el 19 de Sept. de 2024
There are multiple ways to transfer data from C# to MATLAB and executing MATLAB code in response to events. Here are some efficient methods:
1. MATLAB Engine for .NET
The MATLAB Engine API for .NET allows you to interact with MATLAB directly from a C# application, enabling you to transfer data and execute MATLAB commands. For more details, see the MATLAB Engine API for .NET documentation:
2: Callbacks and Listeners in MATLAB
Use callbacks and listeners to execute MATLAB code in response to events, such as data updates from your C# application.
function myCallback(src, eventData)
// perform action
end
listener = addlistener(netClass, ‘Event’, @(src, eventData) myCallback(src, eventData));
For more on running MATLAB code after a .NET event, go through this MATLAB answer:
Give this a try and see how it goes!
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre .NET Methods in MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!