MATLAB Answers

0

Do not close dsp.TimeScope window after finishing function.

Asked by Danil Voloshko on 13 Mar 2016
Latest activity Answered by Roshin Kadanna Pally on 8 Sep 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

  0 Comments

Sign in to comment.

1 Answer

Answer by Roshin Kadanna Pally on 8 Sep 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.

  0 Comments

Sign in to comment.