Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
x=zeros(n,1);
x(n)=c(n);
for i=n-1:-1:1
x(i)=c(i)-U(i,i+1:n)*x(i+1:n);
end
end
respuesta=struct('L',L,'U',U,'c',c,'x',x,'boo',boo);
end
Pantalla Crout
function varargout = Pantalla_Crout(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Pantalla_Crout_OpeningFcn, ...
'gui_OutputFcn', @Pantalla_Crout_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 Pantalla_Crout_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = Pantalla_Crout_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function Dir_A_Callback(hObject, eventdata, handles)
[filename,pathname]=uigetfile({'*.txt','File Selector'});
fullpathname=strcat(pathname,filename);
set(handles.E_Dir_A,'String',fullpathname);
function E_Dir_A_Callback(hObject, eventdata, handles)
function E_Dir_A_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Dir_b_Callback(hObject, eventdata, handles)
[filename,pathname]=uigetfile({'*.txt','File Selector'});
fullpathname=strcat(pathname,filename);
set(handles.E_Dir_b,'String',fullpathname);
function E_Dir_b_Callback(hObject, eventdata, handles)
function E_Dir_b_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Dir_x_Callback(hObject, eventdata, handles)
[file,path]=uiputfile('*.txt','Guardar X como');
fullpathname=strcat(path,file);
set(handles.E_Dir_x,'String',fullpathname);
function E_Dir_x_Callback(hObject, eventdata, handles)
function E_Dir_x_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Dir_L_Callback(hObject, eventdata, handles)
[file,path]=uiputfile('*.txt','Guardar X como');
fullpathname=strcat(path,file);
set(handles.E_Dir_L,'String',fullpathname);
function E_Dir_L_Callback(hObject, eventdata, handles)
function E_Dir_L_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Dir_U_Callback(hObject, eventdata, handles)
[file,path]=uiputfile('*.txt','Guardar X como');
fullpathname=strcat(path,file);
set(handles.E_Dir_U,'String',fullpathname);
function E_Dir_U_Callback(hObject, eventdata, handles)
function E_Dir_U_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Calcular_Callback(hObject, eventdata, handles)
miArchivo1=get(handles.E_Dir_A,'String');
miArchivo2=get(handles.E_Dir_b,'String');
A=importdata(miArchivo1);
b=importdata(miArchivo2);
R=Metodo_Crout(A,b);
set(handles.Tabla_A,'data',A);
set(handles.Tabla_b,'data',b);
set(handles.Tabla_x,'data',R.x);
set(handles.Tabla_L,'data',R.L);
set(handles.Tabla_U,'data',R.U);
set(handles.Tabla_c,'data',R.c);
txt=get(handles.E_Dir_x,'string');
Guardar_Matriz(R.x,txt);
txt=get(handles.E_Dir_L,'string');
Guardar_Matriz(R.L,txt);
txt=get(handles.E_Dir_U,'string');
Guardar_Matriz(R.U,txt);
txt=get(handles.E_Dir_c,'string');
Guardar_Matriz(R.c,txt);
n=length(R.x);
cla()
axes(handles.Grafica);
title(strcat('Solucion de un sistema de ecuaciones de
',num2str(n),'x',num2str(n)));
switch n
case 2
Grafica_2_Ecuaciones(A,b,R.x);
drawnow
case 3
Grafica_3_Ecuaciones(A,b,R.x);
drawnow
case 4
Grafica_4_Ecuaciones(A,b,R.x);
drawnow
otherwise
warndlg('Grafica no disponible','¡Advertencia, el numero de ecuaciones
no es posible de graficar');
end
hold off
function Regresar_Callback(hObject, eventdata, handles)
close;
Pantalla_Sistema_Ecuaciones;
function Dir_c_Callback(hObject, eventdata, handles)
[file,path]=uiputfile('*.txt','Guardar X como');
fullpathname=strcat(path,file);
set(handles.E_Dir_c,'String',fullpathname);
function E_Dir_c_Callback(hObject, eventdata, handles)
function E_Dir_c_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end