要求MATLAB程序在继续执行之前等待事件的函数 [英] Function to ask a MATLAB program to wait for an event before continuing execution

查看:346
本文介绍了要求MATLAB程序在继续执行之前等待事件的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在同一台计算机上使用两个MATLAB会话来运行两个不同的程序.我的问题是,在某个阶段,第一个程序必须使用第二个程序的某些结果.因此,是否有一个函数可以应用于第一个程序,以期提高结果的显示效果.

I want to use two MATLAB sessions on the same machine to run two different programs. My problem is that at some stage, the first program must use some results of the second program. So, is there a function that may apply to the first program to expect a step up the appearance of a result.

推荐答案

最简单的解决方法是让进程#1在进程#1和进程#2都可以访问的位置创建文件.流程1一直运行到需要流程2的结果为止.此时,它进入循环while exist(myFileName),pause(1),end,这使它等待文件存在的时间,每秒检查一次文件是否消失.写完结果后,进程#2会删除该文件,然后进程#1继续.

The easiest way to solve this is to have process #1 create a file in a place accessible by both process #1 and process #2. Process #1 runs until it gets to the point where it needs the results from process #2. At this point, it goes into a loop while exist(myFileName),pause(1),end, which makes it wait as long as the file exists, checking every second for whether the file's gone. Process #2 removes the file as soon as it's done writing out the results, at which point process #1 continues.

这篇关于要求MATLAB程序在继续执行之前等待事件的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆