Do not close dsp.TimeScope window after finishing function.

2 visualizaciones (últimos 30 días)
Danil Voloshko
Danil Voloshko el 13 de Mzo. de 2016
Respondida: Roshin Kadanna Pally el 8 de Sept. de 2016
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
Roshin Kadanna Pally el 8 de Sept. de 2016
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by