function varargout = Circular_Membrane(varargin)
% CIRCULAR_MEMBRANE M-file for Circular_Membrane.fig
%      CIRCULAR_MEMBRANE, by itself, creates a new CIRCULAR_MEMBRANE or raises the existing
%      singleton*.
%
%      H = CIRCULAR_MEMBRANE returns the handle to a new CIRCULAR_MEMBRANE or the handle to
%      the existing singleton*.
%
% How to use the GUI
%    - Use the sliders in the "Single Mode (enter m, n)" panel to
%    choose m and n, and to see the displacement corresponding to
%    the normal mode u_mn.
%    - Use the sliders in the panel labeled "Superposition of modes
%    (enter weights)" to select the weights of the first 9
%    non-trivial normal modes (u_mn, m = 1, 2, 3 and n = 0, 1, 2), 
%    and to see the displacement associated with the corresponding
%    linear combination.
%    - Click the "Run" button to see the temporal evolution of the
%    membrane.
%    - Click the "Reset" button to reinitializes the GUI.
% 
% Developed by Luis Garcia-Naranjo, Mathematics Department, University
% of Arizona, Spring 2007.
% 

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Circular_Membrane_OpeningFcn, ...
                   'gui_OutputFcn',  @Circular_Membrane_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(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


% --- Executes just before Circular_Membrane is made visible.
function Circular_Membrane_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Circular_Membrane (see VARARGIN)

global r th x y

global c delta_t play multi_mode single_mode

global k %k(m,n+1) is the mth positive zero of J_n (Bessel)

% Choose default command line output for Circular_Membrane
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);


% UIWAIT makes Circular_Membrane wait for user response (see UIRESUME)
% uiwait(handles.figure1);


set(handles.figure1,'Name',' Circular Elastic Membrane');
axes(handles.axes1)


c=1;  % value of c in the equation u_tt = c^2 Lap(u)
      % We take characteristic time to be 1 and characteristic
      % length scale to be 1 (radius of the disk)
delta_t = 0.06; % time step for simulation
play=0; % flag for running simulation

%The following constants are important to define the eigenfunctions
%of the Laplacian in polar coordinates with Dirichlet boundary
%conditions:
%Let J_n denote the n^th Bessel function of the first kind
% k(i,j) is the i^th positive zero of J_{j-1}
%First Positive Zeros of J_0 
k(1,1)=2.4048;
k(2,1)=5.5201;
k(3,1)=8.6537;
k(4,1)=11.7915;
k(5,1)=14.9309;
%First Positive Zeros of J_1
k(1,2)=3.8317;
k(2,2)=7.0156;
k(3,2)=10.1735;
k(4,2)=13.3237;
k(5,2)=16.4706;
%First Positive Zeros of J_2
k(1,3)=5.1356;
k(2,3)=8.4172;
k(3,3)=11.6198;
k(4,3)=14.7960;
k(5,3)=17.9598;
%First Positive Zeros of J_3
k(1,4)=6.3802;
k(2,4)=9.7610;
k(3,4)=13.0152;
k(4,4)=16.2235;
k(5,4)=19.4094;
%First Positive Zeros of J_4
k(1,5)=7.5883;
k(2,5)=11.0647;
k(3,5)=14.3725;
k(4,5)=17.6160;
k(5,5)=20.8269;
%First Positive Zeros of J_5
k(1,6)=8.7715;
k(2,6)=12.3386;
k(3,6)=15.7002;
k(4,6)=18.9801;
k(5,6)=22.2178;


%Define coordinates for the membrane
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
[x,y] = pol2cart(th,r);

% Flat Membrane
mesh(x,y,zeros(size(x)));
zlim([-7 7])
axis off
view(-3,62)
%rotate3d ---> Enable this feature is in Stand by.


%Set slider Values at the beginning

m=get(handles.slider_m,'Value');
set(handles.value_m,'String',m);
n=get(handles.slider_n,'Value');
set(handles.value_n,'String',n);

a(1,1)=get(handles.slider_10,'Value');
set(handles.value_10,'String',a(1,1));

a(2,1)=get(handles.slider_20,'Value');
set(handles.value_20,'String',a(2,1));

a(3,1)=get(handles.slider_30,'Value');
set(handles.value_30,'String',a(3,1));

a(1,2)=get(handles.slider_11,'Value');
set(handles.value_11,'String',a(1,2));

a(2,2)=get(handles.slider_21,'Value');
set(handles.value_21,'String',a(2,2));

a(3,2)=get(handles.slider_31,'Value');
set(handles.value_31,'String',a(3,2));

a(1,3)=get(handles.slider_12,'Value');
set(handles.value_12,'String',a(1,3));

a(2,3)=get(handles.slider_22,'Value');
set(handles.value_22,'String',a(2,3));

a(3,3)=get(handles.slider_32,'Value');
set(handles.value_32,'String',a(3,3));




%Set initial condition for single
%mode feature.
function initial_single(hObject,eventdata,handles)

global r th x y

global c delta_t play multi_mode single_mode

global k


single_mode=1; %flag for single-mode feature

multi_mode=0;  %flag for multi-mode feature 

play=0;        %flag to run simulation  


%Obtain wave vector of single mode feature
m=get(handles.slider_m,'Value');
m=round(m);
set(handles.value_m,'String',m);
n=get(handles.slider_n,'Value');
n=round(n);
set(handles.value_n,'String',n);





%Set the values of the multi-mode sliders to zero
set(handles.slider_10,'Value',0);
set(handles.value_10,'String',0);

set(handles.slider_20,'Value',0);
set(handles.value_20,'String',0);

set(handles.slider_30,'Value',0);
set(handles.value_30,'String',0);

set(handles.slider_11,'Value',0);
set(handles.value_11,'String',0);

set(handles.slider_21,'Value',0);
set(handles.value_21,'String',0);

set(handles.slider_31,'Value',0);
set(handles.value_31,'String',0);

set(handles.slider_12,'Value',0);
set(handles.value_12,'String',0);

set(handles.slider_22,'Value',0);
set(handles.value_22,'String',0);

set(handles.slider_32,'Value',0);
set(handles.value_32,'String',0);


%Define coordinates for the membrane
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
[x,y] = pol2cart(th,r);

%Shape of the membrane
if m==0
    u=zeros(size(x));
else
    u = 5*besselj(n,k(m,n+1)*r).*cos(n*th);
end

%Plot the membrane
mesh(x,y,u);
zlim([-7 7])
axis off
view(-3,62)
%rotate3d -----> Enabling this feature is in Stand by





%Set initial condition for multi
%mode feature.
function initial_multi(hObject,eventdata,handles)

global r th x y

global c delta_t play multi_mode single_mode

global k


single_mode=0; %flag for single-mode feature

multi_mode=1;  %flag for multi-mode feature 

play=0;        %flag to run simulation  



%Get the values of the multi-mode sliders 
a(1,1)=get(handles.slider_10,'Value');
set(handles.value_10,'String',a(1,1));

a(2,1)=get(handles.slider_20,'Value');
set(handles.value_20,'String',a(2,1));

a(3,1)=get(handles.slider_30,'Value');
set(handles.value_30,'String',a(3,1));

a(1,2)=get(handles.slider_11,'Value');
set(handles.value_11,'String',a(1,2));

a(2,2)=get(handles.slider_21,'Value');
set(handles.value_21,'String',a(2,2));

a(3,2)=get(handles.slider_31,'Value');
set(handles.value_31,'String',a(3,2));

a(1,3)=get(handles.slider_12,'Value');
set(handles.value_12,'String',a(1,3));

a(2,3)=get(handles.slider_22,'Value');
set(handles.value_22,'String',a(2,3));

a(3,3)=get(handles.slider_32,'Value');
set(handles.value_32,'String',a(3,3));




%Set sliders of single mode feature to zero
set(handles.slider_m,'Value',0);
set(handles.value_m,'String',0);
set(handles.slider_n,'Value',0);
set(handles.value_n,'String',0);


%Define coordinates for the membrane
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
[x,y] = pol2cart(th,r);


%Shape of the membrane (add all the modes with their weights)
u=zeros(size(x));
for i=1:3
    for j=1:3
        u = u+ a(i,j)*besselj(j-1,k(i,j)*r).*cos((j-1)*th);
    end
end

%Plot the membrane
mesh(x,y,u);
zlim([-7 7])
axis off
view(-3,62)
%rotate3d -----> Enabling this feature is in Stand by




%Time evolution of the modes
function evolve(hObject,eventdata,handles)

global r th x y

global c delta_t play multi_mode single_mode

global k

play=1;  %flag for running simulation


%Define coordinates for the membrane
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
[x,y] = pol2cart(th,r);

%Run simulation if multi-mode feature is activated
if multi_mode==1
    
    %Determine weights of the initial condition and frequencies of 
    %oscillation of the different modes
    a(1,1)=get(handles.slider_10,'Value');

    a(2,1)=get(handles.slider_20,'Value');

    a(3,1)=get(handles.slider_30,'Value');

    a(1,2)=get(handles.slider_11,'Value');

    a(2,2)=get(handles.slider_21,'Value');

    a(3,2)=get(handles.slider_31,'Value');

    a(1,3)=get(handles.slider_12,'Value');

    a(2,3)=get(handles.slider_22,'Value');

    a(3,3)=get(handles.slider_32,'Value');

    %Evolve
    for t=0:delta_t:30
        if play==0  %Stop simulation if other buttons or sliders are activated
            break
        end
        u=zeros(size(x));
        for i=1:3
            for j=1:3
                u = u+ a(i,j)*cos(c*k(i,j)*t)*besselj(j-1,k(i,j)*r).*cos((j-1)*th);
            end
        end
        mesh(x,y,u);
        zlim([-7 7])
        axis off
        view(-3,62)
        %rotate3d ---> Enable this feature is in Stand by.

        pause(0.15) %Pause to see image
    end
    %Plot back the initial condition
    a(1,1)=get(handles.slider_10,'Value');

    a(2,1)=get(handles.slider_20,'Value');

    a(3,1)=get(handles.slider_30,'Value');

    a(1,2)=get(handles.slider_11,'Value');

    a(2,2)=get(handles.slider_21,'Value');

    a(3,2)=get(handles.slider_31,'Value');

    a(1,3)=get(handles.slider_12,'Value');

    a(2,3)=get(handles.slider_22,'Value');

    a(3,3)=get(handles.slider_32,'Value');
    
    u=zeros(size(x));
    
    for i=1:3
        for j=1:3
            u = u+ a(i,j)*besselj(j-1,k(i,j)*r).*cos((j-1)*th);
        end
    end

    %Plot the membrane
    mesh(x,y,u);
    zlim([-7 7])
    axis off
    view(-3,62)
    %rotate3d ---> Enable this feature is in Stand by.

end


%Run simulation if single-mode feature is activated
if single_mode==1
    
    %Determine mode to be evolved
    m=get(handles.slider_m,'Value');
    m=round(m);
    
    n=get(handles.slider_n,'Value');
    n=round(n);
    
   
    %evolve
    for t=0:delta_t:30
        if play==0
            break %Stop simulation if other buttons or sliders are activated
        end
        if m==0
           u=zeros(size(x));
        else
           u = 5*cos(c*k(m,n+1)*t)*besselj(n,k(m,n+1)*r).*cos(n*th);
        end
        mesh(x,y,u);
        view(-3,62)
        zlim([-7 7])
        axis off

        pause(0.15) %pause to see image
    end
    %Plot back the initial condition
    m=get(handles.slider_m,'Value');
    m=round(m);
    n=get(handles.slider_n,'Value');
    n=round(n);
    if m==0
    u=zeros(size(x));
    else
    u = 5*besselj(n,k(m,n+1)*r).*cos(n*th);
    end

    %Plot the membrane
    mesh(x,y,u);
    view(-3,62)
    zlim([-7 7])
    axis off
    %rotate3d ---> Enable this feature is in Stand by.

end










% --- Outputs from this function are returned to the command line.
function varargout = Circular_Membrane_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on slider movement.
function slider_m_Callback(hObject, eventdata, handles)
% hObject    handle to slider_m (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_single(hObject,eventdata,handles)


% --- Executes during object creation, after setting all properties.
function slider_m_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_m (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider_n_Callback(hObject, eventdata, handles)
% hObject    handle to slider_n (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_single(hObject,eventdata,handles)


% --- Executes during object creation, after setting all properties.
function slider_n_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_n (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function value_m_Callback(hObject, eventdata, handles)
% hObject    handle to value_m (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_m as text
%        str2double(get(hObject,'String')) returns contents of value_m as a double


% --- Executes during object creation, after setting all properties.
function value_m_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_m (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function value_n_Callback(hObject, eventdata, handles)
% hObject    handle to value_n (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_n as text
%        str2double(get(hObject,'String')) returns contents of value_n as a double


% --- Executes during object creation, after setting all properties.
function value_n_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_n (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on slider movement.
function slider_10_Callback(hObject, eventdata, handles)
% hObject    handle to slider_10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function value_10_Callback(hObject, eventdata, handles)
% hObject    handle to value_10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_10 as text
%        str2double(get(hObject,'String')) returns contents of value_10 as a double


% --- Executes during object creation, after setting all properties.
function value_10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on slider movement.
function slider_20_Callback(hObject, eventdata, handles)
% hObject    handle to slider_20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_20_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider_30_Callback(hObject, eventdata, handles)
% hObject    handle to slider_30 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_30_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_30 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider_11_Callback(hObject, eventdata, handles)
% hObject    handle to slider_11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider_21_Callback(hObject, eventdata, handles)
% hObject    handle to slider_21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_21_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider_12_Callback(hObject, eventdata, handles)
% hObject    handle to slider_12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider_22_Callback(hObject, eventdata, handles)
% hObject    handle to slider_22 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_22_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_22 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider_32_Callback(hObject, eventdata, handles)
% hObject    handle to slider_32 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_32_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_32 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider_31_Callback(hObject, eventdata, handles)
% hObject    handle to slider_31 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

initial_multi(hObject,eventdata,handles)

% --- Executes during object creation, after setting all properties.
function slider_31_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider_31 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function value_20_Callback(hObject, eventdata, handles)
% hObject    handle to value_20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_20 as text
%        str2double(get(hObject,'String')) returns contents of value_20 as a double


% --- Executes during object creation, after setting all properties.
function value_20_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_20 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function value_30_Callback(hObject, eventdata, handles)
% hObject    handle to value_30 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_30 as text
%        str2double(get(hObject,'String')) returns contents of value_30 as a double


% --- Executes during object creation, after setting all properties.
function value_30_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_30 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function value_11_Callback(hObject, eventdata, handles)
% hObject    handle to value_11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_11 as text
%        str2double(get(hObject,'String')) returns contents of value_11 as a double


% --- Executes during object creation, after setting all properties.
function value_11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function value_21_Callback(hObject, eventdata, handles)
% hObject    handle to value_21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_21 as text
%        str2double(get(hObject,'String')) returns contents of value_21 as a double


% --- Executes during object creation, after setting all properties.
function value_21_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_21 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function value_31_Callback(hObject, eventdata, handles)
% hObject    handle to value_31 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_31 as text
%        str2double(get(hObject,'String')) returns contents of value_31 as a double


% --- Executes during object creation, after setting all properties.
function value_31_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_31 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function value_12_Callback(hObject, eventdata, handles)
% hObject    handle to value_12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_12 as text
%        str2double(get(hObject,'String')) returns contents of value_12 as a double


% --- Executes during object creation, after setting all properties.
function value_12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function value_22_Callback(hObject, eventdata, handles)
% hObject    handle to value_22 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_22 as text
%        str2double(get(hObject,'String')) returns contents of value_22 as a double


% --- Executes during object creation, after setting all properties.
function value_22_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_22 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function value_32_Callback(hObject, eventdata, handles)
% hObject    handle to value_32 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of value_32 as text
%        str2double(get(hObject,'String')) returns contents of value_32 as a double


% --- Executes during object creation, after setting all properties.
function value_32_CreateFcn(hObject, eventdata, handles)
% hObject    handle to value_32 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in Runbutton.
function Runbutton_Callback(hObject, eventdata, handles)
% hObject    handle to Runbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

evolve(hObject,eventdata,handles)

% --- Executes on button press in Resetbutton.
function Resetbutton_Callback(hObject, eventdata, handles)
% hObject    handle to Resetbutton (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global  play

play=0;



set(handles.slider_m,'Value',0);
set(handles.value_m,'String',0);

set(handles.slider_n,'Value',0);
set(handles.value_n,'String',0);


set(handles.slider_10,'Value',0);
set(handles.value_10,'String',0);

set(handles.slider_20,'Value',0);
set(handles.value_20,'String',0);

set(handles.slider_30,'Value',0);
set(handles.value_30,'String',0);

set(handles.slider_11,'Value',0);
set(handles.value_11,'String',0);

set(handles.slider_21,'Value',0);
set(handles.value_21,'String',0);

set(handles.slider_31,'Value',0);
set(handles.value_31,'String',0);

set(handles.slider_12,'Value',0);
set(handles.value_12,'String',0);

set(handles.slider_22,'Value',0);
set(handles.value_22,'String',0);

set(handles.slider_32,'Value',0);
set(handles.value_32,'String',0);

%Define coordinates for the membrane
[th,r] = meshgrid((0:5:360)*pi/180,0:.05:1);
[x,y] = pol2cart(th,r);

% Flat Membrane
mesh(x,y,zeros(size(x)));
zlim([-7 7])
view(-3,62)
axis off
