Problem with multitasking matlab simulink in c#
Show older comments
I used c# Task class to run several Simulink simulations asynchronously as below: The code reads lines of data from a file and creates a task for each record. Each task opens a matlab single and runs a Simulink then gets back the result and adds it to a list. When I run my code on a regular pc, the code works fine and I can use the cpus up to 100% but The problem is when I run the same code on a server with 2 xeon cpus, each simulation task takes more time and also the cpus never get to 100% Struct Options{ // some variables here }
ForEach (var line in Lines) { Options op = new Optiones(){ //variables set based on line }; Task task = new Task(RunAsync, op); task.Run(); }
Private Void RunAsync(Object op) { MLapp.mlapp matlab; Type Matlabtype = Type.GetTypeFromProgID("Matlab.Application.Single"); Matlab = (MLApp.MLApp)Activator.CreatInstance(MatlabType);
// put some data into matlab // run Simulink // get back result and add it to a list matlab.Quit();
Answers (0)
Categories
Find more on Call MATLAB from .NET in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!