Can I allow events in Excel while running Matlab script using spreadsheet link?
古いコメントを表示
I am using Spreadsheet Link to run a Matlab function from Excel with VBA. The script takes a while to run and sometimes I want to stop it before it completes. I would like to be able to do this from an Excel userform.
Here is how my Excel sheet works:
- User fills in cells in an Excel column with values to be used as inputs to a Matlab function. The same Matlab function will be called for each row in the column.
- User clicks a command button, starting a Macro
- The macro displays a userform, telling the user that the Matlab script is running. This is all the user sees until the Macro is finished.
- Macro gets the first input from the excel sheet. This input is used to call a Matlab function with spreadsheet link.
- Macro calls the Matlab function and waits for it to return a value. User can't do anything until the Matlab function returns a value. Excel is essentially frozen.
- When a value is returned, macro goes to the next input in the excel sheet and runs the Matlab function again with this new input. It continues to do this for each row value in the Excel column.
- When the Matlab function is finished for the last input in the excel sheet, all of the results are put in the sheet, formatted, etc. (VBA stuff)
- Macro ends and user can go back to using Excel
The bold step is what I want to change. The Matlab function only takes about 5 seconds to run but sometimes the user asks for a few hundred iterations so it can take 30 min or so to finish them all. If the user starts the macro, there is no way to stop it without Ctrl+break or something similar.
I would like to have a "Stop" button on my userform that allow the user to stop the Matlab script from within Excel so they don't have to wait for all iterations to complete. The only thing stopping me from doing this is Matlab is the primary process while the function is running. If I put a button in the userform, clicking it does nothing while the Matlab function is running. My cursor is stuck on "waiting" until the macro is complete.
I don't necessarily need to stop the Matlab function in its tracks. I would be happy if when I press the "Stop" button, the current iteration of the Matlab function finishes, then the remaining ones are skipped. I just want to be able to cancel the remaining iterations, mid-macro.
Any help is appreciated!
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Customization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!