Can I run MATLAB function from each excel file using macro at the same time?

9 ビュー (過去 30 日間)
구구
구구 2022 年 10 月 7 日
回答済み: Eswaramoorthy 2023 年 6 月 7 日
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
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
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!

カテゴリ

Help Center および File ExchangeData Export to MATLAB についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by