function varargout = SE3x3(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @SE3x3_OpeningFcn, ...
                   'gui_OutputFcn',  @SE3x3_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 SE3x3_OpeningFcn(hObject, eventdata, handles, varargin)

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

handles.output = hObject;

guidata(hObject, handles);

function varargout = SE3x3_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles.output;

function X11_Callback(hObject, eventdata, handles)

function X11_CreateFcn(hObject, eventdata, handles)

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.Z13,'String');
D = get(handles.X21,'String');
E = get(handles.Y22,'String');
F = get(handles.Z23,'String');
G = get(handles.X31,'String');
H = get(handles.Y32,'String');
I = get(handles.Z33,'String');

J = get(handles.TI1,'String');
K = get(handles.TI2,'String');
L = get(handles.TI3,'String');

if isempty(A) || isempty(B) || isempty(C) || isempty(D) || isempty(E) || isempty(F) || isempty(G) || isempty(H) || isempty(I) || isempty(J) || isempty(K) || isempty(L)
    
        warndlg('Rellene Los Espacios Faltantes','Mensaje De Alerta');
        set(handles.RX,'String','')
        set(handles.RY,'String','')
        set(handles.RZ,'String','')
        set(handles.RFX,'String','')
        set(handles.RFY,'String','')
        set(handles.RFZ,'String','')
    
else

        X11 = str2double(A);
        Y12 = str2double(B);
        Z13 = str2double(C);
        X21 = str2double(D);
        Y22 = str2double(E);
        Z23 = str2double(F);
        X31 = str2double(G);
        Y32 = str2double(H);
        Z33 = str2double(I);

        TI1 = str2double(J);
        TI2 = str2double(K);
        TI3 = str2double(L);

                M = [X11 Y12 Z13;X21 Y22 Z23;X31 Y32 Z33];

                N = [TI1;TI2;TI3];

                INV = inv(M);

                SOL = INV*N;
                
                format rat
                
                CCC = rat(SOL(1,1))
                DDD = rat(SOL(2,1))
                EEE = rat(SOL(3,1))

        set(handles.RX,'String',SOL(1,1))
        set(handles.RY,'String',SOL(2,1))
        set(handles.RZ,'String',SOL(3,1))
        
        set(handles.RFX,'String',CCC)
        set(handles.RFY,'String',DDD)
        set(handles.RFZ,'String',EEE)

end

function Regresar_Callback(hObject, eventdata, handles)
close(SE3x3);
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.Z13,'String','');
D = set(handles.X21,'String','');
E = set(handles.Y22,'String','');
F = set(handles.Z23,'String','');
G = set(handles.X31,'String','');
H = set(handles.Y32,'String','');
I = set(handles.Z33,'String','');

J = set(handles.TI1,'String','');
K = set(handles.TI2,'String','');
L = set(handles.TI3,'String','');

O = set(handles.RX,'String','');
P = set(handles.RY,'String','');
Q = set(handles.RZ,'String','');

RR = set(handles.RFX,'String','');
SS = set(handles.RFY,'String','');
PP = set(handles.RFZ,'String','');



function X31_Callback(hObject, eventdata, handles)

function X31_CreateFcn(hObject, eventdata, handles)

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

function Y32_Callback(hObject, eventdata, handles)

function Y32_CreateFcn(hObject, eventdata, handles)

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

function TI3_Callback(hObject, eventdata, handles)

function TI3_CreateFcn(hObject, eventdata, handles)

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

function Z13_Callback(hObject, eventdata, handles)

function Z13_CreateFcn(hObject, eventdata, handles)

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

function Z23_Callback(hObject, eventdata, handles)

function Z23_CreateFcn(hObject, eventdata, handles)

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

function Z33_Callback(hObject, eventdata, handles)

function Z33_CreateFcn(hObject, eventdata, handles)

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