function varargout = Complexsounds(varargin)


%%%Dr. Ignacio Serrano-Pedraza 2018
%%%iserrano@ucm.es


% COMPLEXSOUNDS MATLAB code for Complexsounds.fig
%      COMPLEXSOUNDS, by itself, creates a new COMPLEXSOUNDS or raises the existing
%      singleton*.
%
%      H = COMPLEXSOUNDS returns the handle to a new COMPLEXSOUNDS or the handle to
%      the existing singleton*.
%
%      COMPLEXSOUNDS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in COMPLEXSOUNDS.M with the given input arguments.
%
%      COMPLEXSOUNDS('Property','Value',...) creates a new COMPLEXSOUNDS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Complexsounds_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Complexsounds_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Complexsounds

% Last Modified by GUIDE v2.5 17-Nov-2017 19:11:25

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @Complexsounds_OpeningFcn, ...
    'gui_OutputFcn',  @Complexsounds_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 Complexsounds is made visible.
function Complexsounds_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 Complexsounds (see VARARGIN)

% Choose default command line output for Complexsounds
handles.output = hObject;
% Play_sound handles structure
guidata(hObject, handles);
playsound=0;
set(handles.radiobutton1,'Value',1);
Plot_figure(hObject, eventdata, handles,playsound)


function Plot_figure(hObject, eventdata, handles,playsound)
expt = getexpt(handles);

frecuenciamuestreo=expt.Framerate;
if expt.Duration<=0;expt.Duration=0.001;set(handles.Duration,'string',0.001);end
duracion=expt.Duration; %seconds

if expt.amplitude1<0;expt.amplitude=0;set(handles.Amplitude1,'string',0);end
if expt.amplitude2<0;expt.amplitude=0;set(handles.Amplitude2,'string',0);end
if expt.amplitude3<0;expt.amplitude=0;set(handles.Amplitude3,'string',0);end
if expt.amplitude4<0;expt.amplitude=0;set(handles.Amplitude4,'string',0);end
if expt.amplitude5<0;expt.amplitude=0;set(handles.Amplitude5,'string',0);end
if expt.Temporal_frequency1==0;expt.Temporal_frequency1=1;set(handles.Temporal_frequency1,'string',1);end
if expt.Temporal_frequency2==0;expt.Temporal_frequency2=1;set(handles.Temporal_frequency2,'string',1);end
if expt.Temporal_frequency3==0;expt.Temporal_frequency3=1;set(handles.Temporal_frequency3,'string',1);end
if expt.Temporal_frequency4==0;expt.Temporal_frequency4=1;set(handles.Temporal_frequency4,'string',1);end
if expt.Temporal_frequency5==0;expt.Temporal_frequency5=1;set(handles.Temporal_frequency5,'string',1);end

t=[0:1/frecuenciamuestreo:duracion-(1/frecuenciamuestreo)]';
if expt.radiobutton1==1
    y1=expt.amplitude1*cos(2*pi*expt.Temporal_frequency1*t+expt.PHASE1);
else
    y1=0*ones(length(t),1);
end
if expt.radiobutton2==1
    y2=expt.amplitude2*cos(2*pi*expt.Temporal_frequency2*t+expt.PHASE2);
else
    y2=0*ones(length(t),1);
end
if expt.radiobutton3==1
    y3=expt.amplitude3*cos(2*pi*expt.Temporal_frequency3*t+expt.PHASE3);
else
    y3=0*ones(length(t),1);
end
if expt.radiobutton4==1
    y4=expt.amplitude4*cos(2*pi*expt.Temporal_frequency4*t+expt.PHASE4);
else
    y4=0*ones(length(t),1);
end
if expt.radiobutton5==1
    y5=expt.amplitude5*cos(2*pi*expt.Temporal_frequency5*t+expt.PHASE5);
else
    y5=0*ones(length(t),1);
end

y=y1+y2+y3+y4+y5;


axes(handles.Plot1);
cla;
plot(t,y,'b-');
title('Time plot')
xlabel('Time (msec)')
ylabel('Amplitude')
if sum(y)==0
axis([0 expt.ejeX -0.1 0.1])
else 
axis([0 expt.ejeX -(max(abs(y))+0.2*max(abs(y))) max(abs(y))+0.2*max(abs(y))])
end
if playsound==1
    sound(y,frecuenciamuestreo)
end

Y=fftshift(fft(y));
modulo=abs(Y)'*2*(1/length(y));
fase=angle(Y)';
n=length(y);
freq=(-fix(n/2):fix((n-1)/2))/duracion;

axes(handles.Plot2);
cla;

semilogx(freq([round(length(freq)/2+1):end]),modulo([round(length(freq)/2+1):end]),'b-');
title('Amplitude spectrum')
xlabel('Temporal frequency (Hz)')
ylabel('Amplitude')

if sum(y)==0
axis([20 15000 0 1])
else
axis([20 15000 0 max(modulo([round(length(freq)/2+1):end]))+0.2*max(modulo([round(length(freq)/2+1):end]))])
end





% --- Outputs from this function are returned to the command line.
function varargout = Complexsounds_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 button press in Play_sound.
function Play_sound_Callback(hObject, eventdata, handles)
% hObject    handle to Play_sound (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
playsound=1;
Plot_figure(hObject, eventdata, handles,playsound)



% --------------------------------------------------------------------
function OpenMenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to OpenMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
file = uigetfile('*.fig');
if ~isequal(file, 0)
    open(file);
end


% --- Executes during object creation, after setting all properties.
function Amplitude1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Amplitude1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
function Amplitude1_Callback(hObject, eventdata, handles)
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

function expt = getexpt(handles)
% Reads off key data from GUI
%expt = handles.expt;
A = get(handles.Amplitude1,'string');
expt.amplitude1 = str2double(A);
A = get(handles.Amplitude2,'string');
expt.amplitude2 = str2double(A);
A = get(handles.Amplitude3,'string');
expt.amplitude3 = str2double(A);
A = get(handles.Amplitude4,'string');
expt.amplitude4 = str2double(A);
A = get(handles.Amplitude5,'string');
expt.amplitude5 = str2double(A);

TF = get(handles.Temporal_frequency1,'string');
expt.Temporal_frequency1 = str2double(TF);
TF = get(handles.Temporal_frequency2,'string');
expt.Temporal_frequency2 = str2double(TF);
TF = get(handles.Temporal_frequency3,'string');
expt.Temporal_frequency3 = str2double(TF);
TF = get(handles.Temporal_frequency4,'string');
expt.Temporal_frequency4 = str2double(TF);
TF = get(handles.Temporal_frequency5,'string');
expt.Temporal_frequency5 = str2double(TF);

PHASE = get(handles.Phase1,'string');
expt.PHASE1 = str2double(PHASE);
PHASE = get(handles.Phase2,'string');
expt.PHASE2 = str2double(PHASE);
PHASE = get(handles.Phase3,'string');
expt.PHASE3 = str2double(PHASE);
PHASE = get(handles.Phase4,'string');
expt.PHASE4 = str2double(PHASE);
PHASE = get(handles.Phase5,'string');
expt.PHASE5 = str2double(PHASE);

Duration = get(handles.Duration,'string');
expt.Duration = str2double(Duration);
Framerate = get(handles.Framerate,'string');
expt.Framerate = str2double(Framerate);
expt.ejeX = get(handles.axisX,'value');

expt.radiobutton1= get(handles.radiobutton1,'value');
expt.radiobutton2= get(handles.radiobutton2,'value');
expt.radiobutton3= get(handles.radiobutton3,'value');
expt.radiobutton4= get(handles.radiobutton4,'value');
expt.radiobutton5= get(handles.radiobutton5,'value');



function Temporal_frequency1_Callback(hObject, eventdata, handles)
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Temporal_frequency1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency1 (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 Phase1_Callback(hObject, eventdata, handles)
% hObject    handle to Phase1 (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 Phase1 as text
%        str2double(get(hObject,'String')) returns contents of Phase1 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Phase1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Phase1 (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 Plot_figure.
function Plot_figure_Callback(hObject, eventdata, handles)
% hObject    handle to Plot_figure (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)



function Duration_Callback(hObject, eventdata, handles)
% hObject    handle to Duration (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 Duration as text
%        str2double(get(hObject,'String')) returns contents of Duration as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Duration_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Duration (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 Framerate_Callback(hObject, eventdata, handles)
% hObject    handle to Framerate (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 Framerate as text
%        str2double(get(hObject,'String')) returns contents of Framerate as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Framerate_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Framerate (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 CloseMenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to CloseMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
selection = questdlg(['Close ' get(handles.axixX,'Name') '?'],...
    ['Close ' get(handles.axixX,'Name') '...'],...
    'Yes','No','Yes');
if strcmp(selection,'No')
    return;
end

delete(handles.axixX)
% --------------------------------------------------------------------
function PrintMenuItem_Callback(hObject, eventdata, handles)
% hObject    handle to PrintMenuItem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
printdlg(handles.axixX)

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


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


set(handles.Amplitude1, 'String', 0.3);
set(handles.Temporal_frequency1,  'String', 1000);
set(handles.Phase1, 'String', 0);

set(handles.Amplitude2, 'String', 0.2);
set(handles.Temporal_frequency2,  'String', 1500);
set(handles.Phase2, 'String', -3.14);

set(handles.Amplitude3, 'String', 0.1);
set(handles.Temporal_frequency3,  'String', 2000);
set(handles.Phase3, 'String', 0);

set(handles.Amplitude4, 'String', 0.1);
set(handles.Temporal_frequency4,  'String', 2500);
set(handles.Phase4, 'String', 1.57);

set(handles.Amplitude5, 'String', 0.05);
set(handles.Temporal_frequency5,  'String', 3000);
set(handles.Phase5, 'String', 0);


set(handles.Duration, 'String', 1);
set(handles.Framerate, 'String', 44100);
set(handles.axisX,'Value',0.005);

set(handles.radiobutton1,'Value',1);
set(handles.radiobutton2,'Value',0);
set(handles.radiobutton3,'Value',0);
set(handles.radiobutton4,'Value',0);
set(handles.radiobutton5,'Value',0);

playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

%set(handles.unitgroup, 'SelectedObject', handles.english);

%set(handles.text4, 'String', 'lb/cu.in');
%set(handles.text5, 'String', 'cu.in');
%set(handles.text6, 'String', 'lb');

% Update handles structure
%guidata(handles.axixX, handles);





% --- Executes on slider movement.
function axisX_Callback(hObject, eventdata, handles)
% hObject    handle to axisX (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%get(hObject,'Value')
% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function axisX_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axisX (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 Freqslider_Callback(hObject, eventdata, handles)
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


% --- Executes during object creation, after setting all properties.
function Freqslider_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Freqslider (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 button press in radiobuttonslider.
function radiobuttonslider_Callback(hObject, eventdata, handles)
% hObject    handle to radiobuttonslider (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobuttonslider
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

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

% Hint: get(hObject,'Value') returns toggle state of radiobutton1
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


function Temporal_frequency2_Callback(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency2 (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 Temporal_frequency2 as text
%        str2double(get(hObject,'String')) returns contents of Temporal_frequency2 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Temporal_frequency2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency2 (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 Amplitude2_Callback(hObject, eventdata, handles)
% hObject    handle to Amplitude2 (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 Amplitude2 as text
%        str2double(get(hObject,'String')) returns contents of Amplitude2 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Amplitude2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Amplitude2 (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 Phase2_Callback(hObject, eventdata, handles)
% hObject    handle to Phase2 (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 Phase2 as text
%        str2double(get(hObject,'String')) returns contents of Phase2 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Phase2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Phase2 (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 radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


function Temporal_frequency3_Callback(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency3 (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 Temporal_frequency3 as text
%        str2double(get(hObject,'String')) returns contents of Temporal_frequency3 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Temporal_frequency3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency3 (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 Amplitude3_Callback(hObject, eventdata, handles)
% hObject    handle to Amplitude3 (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 Amplitude3 as text
%        str2double(get(hObject,'String')) returns contents of Amplitude3 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Amplitude3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Amplitude3 (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 Phase3_Callback(hObject, eventdata, handles)
% hObject    handle to Phase3 (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 Phase3 as text
%        str2double(get(hObject,'String')) returns contents of Phase3 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Phase3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Phase3 (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 radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton3
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


function Temporal_frequency4_Callback(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency4 (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 Temporal_frequency4 as text
%        str2double(get(hObject,'String')) returns contents of Temporal_frequency4 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Temporal_frequency4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency4 (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 Amplitude4_Callback(hObject, eventdata, handles)
% hObject    handle to Amplitude4 (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 Amplitude4 as text
%        str2double(get(hObject,'String')) returns contents of Amplitude4 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Amplitude4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Amplitude4 (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 Phase4_Callback(hObject, eventdata, handles)
% hObject    handle to Phase4 (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 Phase4 as text
%        str2double(get(hObject,'String')) returns contents of Phase4 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Phase4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Phase4 (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 radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton4
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)


function Temporal_frequency5_Callback(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency5 (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 Temporal_frequency5 as text
%        str2double(get(hObject,'String')) returns contents of Temporal_frequency5 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Temporal_frequency5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Temporal_frequency5 (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 Amplitude5_Callback(hObject, eventdata, handles)
% hObject    handle to Amplitude5 (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 Amplitude5 as text
%        str2double(get(hObject,'String')) returns contents of Amplitude5 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Amplitude5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Amplitude5 (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 Phase5_Callback(hObject, eventdata, handles)
% hObject    handle to Phase5 (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 Phase5 as text
%        str2double(get(hObject,'String')) returns contents of Phase5 as a double
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)

% --- Executes during object creation, after setting all properties.
function Phase5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Phase5 (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 radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton5
playsound=0;
Plot_figure(hObject, eventdata, handles,playsound)