Do not close dsp.TimeScope window after finishing function.
Mostrar comentarios más antiguos
I have a function for recording audio files. but when function finish execution, it automatically close TimeScope and SpectrumAnalyzer, but not figure that created by 'plot'. How can i fix this?
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
seples=30000;
fs=14000;
recObj = audiorecorder(fs,16,1,1);
% IM USING handles JUST BECOUSE
handles.mic=dsp.AudioRecorder;
handles.mic.SampleRate=14000;
handles.mic.NumChannels=1;
%---------------
handles.Fs=dsp.SpectrumAnalyzer; % THIS IS CLOSING
handles.Fs.TimeSpan=300000;
%--------------
handles.myt=dsp.TimeScope; % THIS IS CLOSING
handles.myt.BufferLength=20*14000;
handles.myt.ShowGrid=true;
handles.myt.TimeSpan=30000;
handles.myt.YLimits=[-0.5 0.5];
%-------------
tic;
whole=[]
while toc<5
in=step(handles.mic);
whole=[whole,in'];
step(handles.Fs,in); % HERE I USE THIS OBJECTS AND SEE THE ANIMATION
step(handles.myt,in);
end
%figure(Fs);
release(handles.mic);
release(handles.Fs);
release(handles.myt);
%tic=0:1/fs:24-1/fs;
plot(in); % THIS IS NOT CLOSING
Respuestas (1)
Roshin Kadanna Pally
el 8 de Sept. de 2016
0 votos
The Scope windows close because the underlying System Objects are deleted. You can declare the variables holding the System Object Scopes as persistent to avoid this.
Categorías
Más información sobre Scopes and Data Logging en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!