0

我有一个简单的 GUI,其中包含两个按钮,一个用于播放 cam 流,另一个用于停止它。

function Play_callback(hObject,eventdata,handles)

Play1 = evalin('base','PlayCam1');
Play2 = evalin('base','PlayCam2');

while (1)
if(Play1 == 1)
...CAM1 STREAM...
end
if(Play2 == 1)
...CAM2 STREAM...
end
end

function StopCam1(hObject,eventdata,handles)
assignin('base','PlayCam1',0);
Play_callback(hObject,eventdata,handles);

上面的代码片段在按钮上传输两个凸轮,但我"Play"需要单独控制"STOP"每个凸轮的 MATLAB 只是冻结,这是为什么呢?"StopCam1""PlayCam1"0"Play"

4

1 回答 1

0

您需要在 while 循环中重新分配 Play1 和 Play2 变量:

function Play_callback(hObject,eventdata,handles)

Play1 = evalin('base','PlayCam1');
Play2 = evalin('base','PlayCam2');

while (1)
Play1 = evalin('base','PlayCam1');
Play2 = evalin('base','PlayCam2');
if(Play1 == 1)
...CAM1 STREAM...
end
if(Play2 == 1)
...CAM2 STREAM...
end
end

或者

function Play_callback(hObject,eventdata,handles)

while (1)
if(evalin('base','PlayCam1')== 1)
...CAM1 STREAM...
end
if(evalin('base','PlayCam2')== 1)
...CAM2 STREAM...
end
end
于 2018-01-05T21:02:00.963 回答