function varargout = IIRell(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @IIRell_OpeningFcn, ...
                   'gui_OutputFcn',  @IIRell_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

function IIRell_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);

function varargout = IIRell_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

function edit1_CreateFcn(hObject, eventdata, handles)

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit1_Callback(hObject, eventdata, handles)
 N = str2num(get(hObject, 'String'));
data = getappdata(gcbf, 'UserData');
data.N = N;
setappdata(gcbf, 'UserData', data);

function edit2_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit2_Callback(hObject, eventdata, handles)
Rp = str2num(get(hObject, 'String'));
data = getappdata(gcbf, 'UserData');
data.Rp = Rp;
setappdata(gcbf, 'UserData', data);

function edit4_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit4_Callback(hObject, eventdata, handles)
Wn = str2num(get(hObject, 'String'));
data = getappdata(gcbf, 'UserData');
data.Wn = Wn;
setappdata(gcbf, 'UserData', data);

function edit5_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function edit5_Callback(hObject, eventdata, handles)
Rs = str2num(get(hObject, 'String'));
data = getappdata(gcbf, 'UserData');
data.Rs = Rs;
setappdata(gcbf, 'UserData', data);

function pushbutton1_Callback(hObject, eventdata, handles)
data = getappdata(gcbf, 'UserData');
[b,a] = ellip(data.N,data.Rp,data.Rs,data.Wn);
disp(b)
disp(a)
w= 0:0.01/pi:pi;
h = freqz(b,a,w);
plot (w/pi,20*log10(abs(h)));grid;
xlabel('\omega/\pi'); ylabel('Gain, dB');

function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function listbox1_Callback(hObject, eventdata, handles)

function pushbutton2_Callback(hObject, eventdata, handles)
data = getappdata(gcbf, 'UserData');
[b,a] = ellip(data.N,data.Rp,data.Rs,data.Wn);
set(handles.listbox1, 'String', b);

function listbox3_CreateFcn(hObject, eventdata, handles)
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

function listbox3_Callback(hObject, eventdata, handles)

function pushbutton3_Callback(hObject, eventdata, handles)
data = getappdata(gcbf, 'UserData');
[b,a] = ellip(data.N,data.Rp,data.Rs,data.Wn);
set(handles.listbox3, 'String', a);

