function varargout = validacion(varargin)
% VALIDACION M-file for validacion.fig
%      VALIDACION, by itself, creates a new VALIDACION or raises the existing
%      singleton*.
%
%      H = VALIDACION returns the handle to a new VALIDACION or the handle to
%      the existing singleton*.
%
%      VALIDACION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in VALIDACION.M with the given input arguments.
%
%      VALIDACION('Property','Value',...) creates a new VALIDACION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before validacion_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to validacion_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

% Copyright 2002-2003 The MathWorks, Inc.

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

% Last Modified by GUIDE v2.5 12-Nov-2005 17:26:14

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

% Choose default command line output for validacion
handles.output = hObject;
flagvalidacion=0;                       % 1=si, 0=no

handles.flagvalidacion=0;
x2=varargin{1};
y2=varargin{2};
canal=varargin{3};
axes(handles.validacion_axes)
plot(x2,y2)
xlabel('t (s)')

if canal==2
    ylabel('Temperatura (ºC)')
elseif canal==3
    ylabel('Humedad (%)')
else
    ylabel('Magnitud (V)');
end

title('Delimitación de la señal entre los extremos seleccionados')
% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = validacion_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
try
    
    varargout{1} = handles.flagvalidacion;
catch
    varargout{1} = 0;
end
closereq;

% --- Executes on button press in si_push.
function si_push_Callback(hObject, eventdata, handles)
% hObject    handle to si_push (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.flagvalidacion=1;
guidata(hObject,handles)
uiresume;

% --- Executes on button press in no_push.
function no_push_Callback(hObject, eventdata, handles)
% hObject    handle to no_push (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.flagvalidacion=0;
guidata(hObject,handles)
uiresume;
