MATLAB fork a(MS-Windows)进程

MATLAB fork a(MS-Windows)进程,matlab,fork,Matlab,Fork,我试图从matlab中派生一个(微软Windows)进程 myCaller = ['theExe.exe' ' its arguments' ' &']; system(myCaller); 然而,我无法实现分叉 最后,我要做的是启动一个(微软Windows)进程,并关闭调用MATLAB例程 对如何实现上述目标有何建议?很难;我正在Ubuntu上做同样的事情 基本上,MATLAB会坐下来等待生成的程序完成,然后再继续自己的过程,尽管最后出现了& 我一直使用的解决方法是使用mex文件创建

我试图从matlab中派生一个(微软Windows)进程

myCaller = ['theExe.exe' ' its arguments' ' &'];
system(myCaller);
然而,我无法实现分叉

最后,我要做的是启动一个(微软Windows)进程,并关闭调用MATLAB例程


对如何实现上述目标有何建议?

很难;我正在Ubuntu上做同样的事情

基本上,MATLAB会坐下来等待生成的程序完成,然后再继续自己的过程,尽管最后出现了
&

我一直使用的解决方法是使用mex文件创建一个单独的线程(使用
pthread
)。当主mex线程退出时,这个单独的线程启动theExe.exe

一些未经测试的黑客将我的代码拼凑在一起,这说明了这个过程:

#include "mex.h"
#include <iostream>
#include "pthread.h" /* for threading */

// thread function which calls system call, and waits for it to finish
void *do_thread(void *pid)
{
  mexPrintf("In thread\n");

  // replace this with your system call - don't know if std::system works on windows?
  std::system("your_system_call"); 

  pthread_exit(NULL);
}

// main mex function
void mexFunction (int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
    pthread_t thread;
    mexPrintf("In main: creating thread\n");
    rc = pthread_create(&thread, NULL, do_thread, (void *)v);    
    return;
}

我承认我不知道如何在Windows上编译它,但Windows上确实存在pthreads版本。

最终,我伪造了fork。。。一个通用函数,通过cmd调用进程,同时继续工作。@Sridutt-Nayak:您只需从matlab调用cmd(MS-Windows命令提示符),然后从open commpand提示符执行所需的进程。
mex mex_filename.cpp -I/usr/include/ -lpthread -lrt