1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global StopNow;
global h1;
%
f0=500; % f0
Fs=10000; % sampling rate
dt=1/Fs;
%
t=0:dt:1023*dt; % time
StopNow = false;
OneInstance=false
%
while ~StopNow,
% boucle d affichage
buf=100*sin(2*pi*f0*t+rand*10);
% fast plot
switch OneInstance % initialisation
case false % on passe ici une fois
axes(handles.axes1);cla; % efface figure
p1=line(t,buf) ; % plot avec memo du handle
drawnow; % line est plus rapide que plot
OneInstance=true; % on est passe par la
case true % on repasse par la
axes(handles.axes1); % selectionne axe
set(p1,'xdata',t,'ydata',buf); % affiche directement dans les datas
drawnow; % affiche la figure
end
pause(0.01);
if StopNow
break
end
end
% --- Executes on button press in stop.
function stop_Callback(hObject, eventdata, handles)
% hObject handle to stop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global StopNow ;
StopNow = true;
% --- Executes on button press in change.
function change_Callback(hObject, eventdata, handles)
% hObject handle to change (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global f0;
f0=str2num(get(handles.val,'Edit')); |
Partager