How can I initiate a while loop with a GUI button (using UI control) and then end that loop with a different GUI button?
Afficher commentaires plus anciens
I am working with a tracking system and I have been using a while loop to continuously scan for data. The whole time I have been terminating the loop with control-c, but now I am manipulating an old GUI and trying to initiate and terminate the loop with buttons in the GUI. I thought this might work but I am not having any luck:
%pivot shift button %collects data while subject performs pivot shift PS_data = uicontrol('Position',[1125 250 100 25],'String','Pivot Shift', 'FontSize',12,'Callback','GUI_data_collection'); %calls data collection
%This ends the pivot shift PivotShiftEndButton = uicontrol('Position',[1125 200 100 25],'String','End Shift',..., 'FontSize',12,'Callback','delete(PS_data)');
fprintf(Ftrak,'C'); shift_data = [];
while ishandle(PS_data)
scan = fscanf(Ftrak,'%f');
scan= scan';
if length(scan) == 7
shift_data = [shift_data;scan];
if shift_data(end,1) == shift_data(end - 1,1)
shift_data(end,:) = [];
end
end
end
1 commentaire
Jan
le 1 Août 2017
Please use the "{} Code" button to format you code, such that it becomes readable. Then explain "not having any luck" with details. It is easier to fix a problem than to guess, what the problem is.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!