Do not close dsp.TimeScope window after finishing function.
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Roshin Kadanna Pally
2016-9-8
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!