Professional Documents
Culture Documents
hfig ud = hn = hd = hf =
= gcf; get(hfig,'UserData'); ud.handles.uis(3); ud.handles.uis(1); ud.handles.ui
s(2);
noise = get(hn,'Value'); degindx = get(hd,'Value'); deg = get(hd,'UserData'); de
gree = deg(degindx); frmindx = get(hf,'Value'); frm = get(hf,'UserData'); frame
= frm(frmindx); update_gui(y,noise,degree,frame) case 'info', ttlStr = 'Savitzky
-Golay Filtering Demo'; hlpStr1= ... ['This demo shows the smoothing of an elect
rocardiogram (ECG) signal' spri ntf('\n')... 'by filtering the noisy ECG with a
Savitzky-Golay FIR filter.' sprintf( '\n')... 'You can vary the noise level of t
he ECG signal to be filtered with the ' sprintf('\n')... 'slider control on the
upper right of the GUI. The parameters of the' s printf('\n')... 'Savitzky-Golay
filter can be changed through the two popup menus provi ded.' sprintf('\n')...
'' sprintf('\n')... 'Savitzky-Golay filters act as smoothers by performing a lea
st squares' sprintf('\n')... 'fitting of a frame of data to a polynomial of a gi
ven degree.' sprintf ('\n')... '' sprintf('\n')... 'The frame size indicates the
number of samples you are using to perfor m' sprintf('\n')... 'the smoothing fo
r each data point. The degree is the order of the poly nomial' sprintf('\n')...
'to which each frame of data is fitted.' sprintf('\n')... '' sprintf('\n')... 'T
he noiseless or ideal ECG is shown at the bottom of the figure for' s printf('\n
')... 'comparison purposes']; helpwin(hlpStr1, ttlStr); case 'done', close(gcf);
end function [s,f] = update_signal(y,noise,degree,frame) %UPDATE_SIGNAL Recalcu
lates the noisy ECG and the filtered ECG signals. v = 0.05*noise*randn(3000,1);
% noise s = y + v; % noisy ecg f = sgolayfilt(s,degree,frame); function update_g
ui(y,noise,degree,frame) %UPDATE_GUI This function is called to update the GUI w
ith the new values.