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

3 Ansichten (letzte 30 Tage)
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 Kommentar
dpb
dpb am 8 Okt. 2022
Only maybe with the parallel toolbox; but I won't guarantee that, even...but, otherwise both MATLAB and EXCEL are single-threaded.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Eswaramoorthy
Eswaramoorthy am 7 Jun. 2023
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!

Kategorien

Mehr zu Data Export to MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by