MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何从C / C ++中止MATLAB m文件功能? (https://www.labfans.com/bbs/showthread.php?t=22791)

poster 2019-12-10 16:49

如何从C / C ++中止MATLAB m文件功能?
 
我将MATLAB项目部署到DLL中,从C ++中调用它,并且效果很好。快乐的时光。

但是,当用户要求取消操作时会发生什么?

我尝试创建一个名为UserAborted的global变量。在MATLAB中运行long函数之前,我将其初始化为0。我还编写了以下两个函数:

function AbortIfUserRequested global UserAborted if (UserAborted == 1) error('User Abort'); end end function UserAbortLongFunction global UserAborted UserAborted = 1; end 我在long函数的循环的每次迭代中都调用AbortIfUserRequested 。我还导出了UserAbortLongFunction 。

我期望在调用UserAbortLongFunction之后不久,长函数将到达对AbortIfUserRequested的调用,并引发错误。

相反,长功能继续工作,直到结束, [I]然后[/I]才做的价值UserAborted得到改变。

我只想在用户要求我时中止该长功能!有什么办法吗?


回答:
Matlab需要提供回调函数来显示执行进度并可能将其暂停。 Google搜索显示很多人都希望这样做,但Mathworks没有实现。



[url=https://stackoverflow.com/questions/1470716]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:20

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.