两种解决方案可能会对您有所帮助。实际上,它有点复杂。解决方案1使用c代码程序的mex方法控制窗口。方案二也比较复杂,使用MATLAB并行工具箱即可。嗯,我建议你使用解决方案 1。
解决方案1:
创建一个 cpp 文件,它控制您的交互式程序(即此处的窗口资源管理器)。代码如下。将代码复制并保存为 MATLAB 当前文件夹中的“ctrlWindow.cpp”。
通过编译器 lcc 编译 ctrlWindow.cpp:
mex -setup % choose compiler: type this command at MATLAB command, then choose lcc complier on windows 32 system
mex ctrlWindow.cpp % compile cpp: you would find ctrlWindow.mexw32 at current folder
在 MATLAB 命令中将 mex 文件作为 m 文件运行:
ctrlWindow('your_program_window_name',command);
即文件夹“myfold”的窗口名称是myfold,它显示在窗口的左上角,输入命令:
ctrlWindow('myfold',6);
这将最小化您的文件夹窗口。我建议你先最小化你的程序窗口,然后再最大化它,参与者会再次关注你的程序:
ctrlWindow('myfold',6);%minimize window
ctrlWindow('myfold',3);%maximize window and participants would focus on this window
命令在这里:
HIDE 0
SHOWNORMAL 1
NORMAL 1
SHOWMINIMIZED 2
SHOWMAXIMIZED 3
MAXIMIZE 3
SHOWNOACTIVATE 4
SHOW 5
MINIMIZE 6
SHOWMINNOACTIVE 7
SHOWNA 8
RESTORE 9
SHOWDEFAULT 10
FORCEMINIMIZE 11
MAX 11
//filename:ctrlWindow.cpp
#include <windows.h>
#include "mex.h"
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
mxChar* winName; //name of window wanted to be found
HWND hwnd; //handle of window
int command; //command of control window
// check number of input
if(nrhs!=2)
mexErrMsgTxt("input must be 2");
// check class of input
if (mxIsChar(prhs[0]))
winName=mxGetChars(prhs[0]);//get name of window
else
mexErrMsgTxt("input 1 should be char -- name of window");
if (mxIsDouble(prhs[1]))
{
command = (int) mxGetScalar(prhs[1]);//get command
if(command<0 || command >11)//check command
mexErrMsgTxt("No such command!!!");
}
else
mexErrMsgTxt("input 2 should be a double");
// find window
hwnd = FindWindowW(NULL, (LPCWSTR)winName);
if(NULL==hwnd)
{
MessageBoxW(NULL,(LPCWSTR) L"Can't find the window!!!",NULL,MB_OK);
return;
}
ShowWindow(hwnd, command);//control the window
}
Solution 2:
matlabpool open 2
open two matlab background, use first control your first program, use second one control your second program.