0
我想显示的情节,然后等待要么光标被点击的情节,或用户通过按一个键来输入数字到Matlab。到目前为止,我知道如何单独使用这两种方法,但我不知道如何让Matlab独立地响应两者。我想你会称之为多线程的一种形式。Matlab的:使光标和键盘输入同时
我的代码,以使响应当光标被点击如下:
h = figure(%{ ... params ...%});
while true
figure(h);
cursor = ginput(1);
% ... process the cursor input ...
end
现在,我想包括以下行以使用户能够从键盘输入一个号码:
num = input('Enter the number: ');
但如果我只添加这对我while循环:
h = figure(%{ ... params ...%});
while true
figure(h);
cursor = ginput(1);
% ... process the cursor input ...
num = input('Enter the number: ');
% ... process the keyboard input ...
end
然后程序将始终等待用户在返回查找光标输入之前从键盘输入数字。但是我希望程序能够独立地响应两者。
解决方案是什么?