function varargout = SE2x2(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @SE2x2_OpeningFcn, ...
                   'gui_OutputFcn',  @SE2x2_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

function SE2x2_OpeningFcn(hObject, eventdata, handles, varargin)

AAAA = imread('Circuitos.jpg');
image(AAAA)
axis off

handles.output = hObject;

guidata(hObject, handles);

function varargout = SE2x2_OutputFcn(hObject, eventdata, handles) 

varargout{1} = handles.output;

function X11_Callback(hObject, eventdata, handles)

function X11_CreateFcn(hObject, eventdata, ~)

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

function X21_Callback(hObject, eventdata, handles)

function X21_CreateFcn(hObject, eventdata, handles)

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

function Y12_Callback(hObject, eventdata, handles)

function Y12_CreateFcn(hObject, eventdata, handles)

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

function Y22_Callback(hObject, eventdata, handles)

function Y22_CreateFcn(hObject, eventdata, handles)

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

function TI1_Callback(hObject, eventdata, handles)

function TI1_CreateFcn(hObject, eventdata, handles)

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

function TI2_Callback(hObject, eventdata, handles)

function TI2_CreateFcn(hObject, eventdata, handles)

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

function Resolver_Callback(hObject, eventdata, handles)

A = get(handles.X11,'String');
B = get(handles.Y12,'String');
C = get(handles.X21,'String');
D = get(handles.Y22,'String');

E = get(handles.TI1,'String');
F = get(handles.TI2,'String');

if isempty(A) || isempty(B) || isempty(C) || isempty(D) || isempty(E) || isempty(F)
    warndlg('Rellene Los Espacios Faltantes','Mensaje De Alerta');
    set(handles.RX,'String','')
    set(handles.RY,'String','')
else

X11 = str2double(A);
Y12 = str2double(B);
X21 = str2double(C);
Y22 = str2double(D);

TI1 = str2double(E);
TI2 = str2double(F);

G = [X11 Y12;X21 Y22];

H = [TI1;TI2];

        INV = inv(G);

        SOL = INV*H;
        
        format rat
        AAA = rat(SOL(1,1))
        BBB = rat(SOL(2,1))

set(handles.RX,'String',SOL(1,1))
set(handles.RY,'String',SOL(2,1))
set(handles.RXF,'String',AAA)
set(handles.RYF,'String',BBB)

end

function Regresar_Callback(hObject, eventdata, handles)
close(SE2x2);
SistemasEcuaciones

function figure1_ButtonDownFcn(hObject, eventdata, handles)

function Limpiar_Callback(hObject, eventdata, handles)

A = set(handles.X11,'String','');
B = set(handles.Y12,'String','');
C = set(handles.X21,'String','');
D = set(handles.Y22,'String','');

E = set(handles.TI1,'String','');
F = set(handles.TI2,'String','');

I = set(handles.RX,'String','');
J = set(handles.RY,'String','');
K = set(handles.RXF,'String','');
L = set(handles.RYF,'String','');
