Can I run MATLAB function from each excel file using macro at the same time?
3 次查看(过去 30 天)
显示 更早的评论
I wanted to run MATLAB function from excel file and it worked using VBA and excel macro.
For parametric study I made several excel file and run the macro from each file.
But when the MATLAB function is running on an excel file, I can not run the function from other excel files.
I want to run same MATLAB function with different inputs at the same time.
Is there any way I can do this?
1 个评论
dpb
2022-10-8
Only maybe with the parallel toolbox; but I won't guarantee that, even...but, otherwise both MATLAB and EXCEL are single-threaded.
回答(1 个)
Eswaramoorthy
2023-6-7
When running MATLAB functions from Excel using VBA macros, MATLAB runs as a separate process and is limited to a single instance. Therefore, running the same MATLAB function with different inputs simultaneously from multiple Excel files is not directly possible.
However, there are a few workarounds you can consider to achieve your goal:
1. Parallel Computing Toolbox: If you have access to the Parallel Computing Toolbox in MATLAB, you can leverage parallel computing to execute the MATLAB function with different inputs simultaneously. Instead of running the MATLAB function from multiple Excel files, you can create a single Excel file that contains all the input data, and then use MATLAB's parallel computing features, such as `parfor` or `parfeval`, to distribute the workload across multiple MATLAB workers.
2. MATLAB Compiler: Another option is to use MATLAB Compiler to compile your MATLAB function into a standalone executable or a shared library. Once compiled, you can call the MATLAB function directly from each Excel file without the need for multiple MATLAB instances. This allows you to execute the MATLAB function with different inputs simultaneously from different Excel files.
3. MATLAB Automation Server: MATLAB Automation Server allows you to remotely control a MATLAB instance from external applications such as Excel using the COM interface. By creating a single MATLAB instance and utilizing the automation server, you can run the MATLAB function with different inputs concurrently from multiple Excel files. This requires some programming in VBA to establish the connection with the MATLAB instance and execute the desired MATLAB functions.
Remember that implementing these workarounds may require additional setup, configuration, and programming, depending on the approach you choose. Consider the complexity of your MATLAB function, the size of the input data, and the resources available to determine the most suitable approach for your specific scenario.
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Export to MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!