Breaking a loop GUI?
古いコメントを表示
Reading in accelerometer data in a GUI code. I'm trying to break the loop while reading by using the following code...
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a = getappdata(handles.text11, 'text11');
%COMPORT
comPort = '/dev/tty.usbmodemfd121';
%READS SERIAL
[accelerometer.s,serialFlag] = setupSerial(comPort);
calCo = calibrate(accelerometer.s);
%READS DATA
while (a == 0)
if (a == 1)
closeSerial
end
[gx gy gz] = readAcc(accelerometer,calCo);
cla;
r = sqrt((gx^2)+(gy^2)+(gz^2));
r
end
guidata(hObject, handles);
My problem is that the data keeps reading even when (a == 1), which is activated from a separate pushbutton. I've already tested the outputs of both each pushbuttons and they do read 0 and 1, but when reading the data, if I press the 1 pushbutton the data will still read.
6 件のコメント
Amed
2013 年 2 月 11 日
Amed
2013 年 2 月 11 日
Amed
2013 年 2 月 11 日
Jan
2013 年 2 月 11 日
@Amed: Please do not bump your question frequently. If the contributors do not know an answer, it does not help to read trhe question one hour later again, as long as no additional information is provided. Thanks.
Amed
2013 年 2 月 14 日
Amed
2013 年 2 月 14 日
回答 (1 件)
Walter Roberson
2013 年 2 月 11 日
while true
drawnow;
a = getappdata(handles.text11, 'text11');
if a == 0; break; end
...
end
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!