【发布时间】:2014-12-14 21:28:37
【问题描述】:
我想显示一个绘图,然后等待或者光标在绘图上被点击,或者用户通过按a在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
然后程序将始终等待用户从键盘输入数字,然后返回寻找光标输入。但我希望程序能够相互独立地响应。
解决办法是什么?
【问题讨论】:
标签: matlab matlab-figure