Matlab - Dudas sobre como hacer un GUI

   
Vista:

Dudas sobre como hacer un GUI

Publicado por Leonel Vigil leonelvigil93@hotmail.com (1 intervención) el 28/10/2012 16:42:04
Hola compañeros, bien quisiera ver si alguien me podria aclarar unas dudas, me encargaron un programa en matlab que calculara el metodo montante, no sabia nada del matlab, asi que no sabia si se podia o no, investige y resulto que se podia hacerlo entonces me puse a hacer el programa, pero ya tengo toda la estructura, el problema es que cuando inserto la matriz para que la calcule no se como se hace no me arroja resultados ni nada :( , quisiera ver si me podrian ayudar a resolverlo

Este es el codigo del metodo montante

function [res,det] = Montante(A,varargin)

% Implementacion del metodo Montante para resolver sistemas de
% ecuaciones lineales y encontrar la inversa de una matriz.
%
% [Inv,det] = Montante(A)
%
% Regresa Inv, la inversa de A, y el determinante de A.
%
% [x,det] = Montante(A,b)
%
% Regresa x, la solucion del sistema Ax=b, y el determinante de A.

MAXPIVOTE = 1;
det = 1;


% Se crea la matriz aumentada
[n,m] = size(A);
if length(varargin)>=1
b = varargin{1}
fprintf(1,'A=')
disp(A)
fprintf (1,'Se crea la matriz aumentada')
A = [A b]
elseif n==m
A = [A eye(n)]
end
[n,m] = size(A)

if n>m
error('n>m en la matriz aumentada')
end
fprintf(1,'Pivote Inicial')
pivAnt = 1; % 'pivote inicial'
for i=1:n
if MAXPIVOTE

% 'Encontrar renglon del maximo pivote'

columna = find(abs(A(:,i))==max(abs(A(i:n,i))),1,'last')

if columna~=i
% 'Intercambiar renglones'
fprintf(1,'Se intercambian renglones')
det = -det;
rPivote = A(columna,:)
A(columna,:) = A(i,:)
A(i,:) = rPivote
end
end
fprintf(1,'Pivote Actual')
piv = A(i,i) % pivote actual

% Salir si determinante es cero
if piv==0
error('Determinante es igual a cero')
end

% Hacer ceros en la columna i
fprintf(1,'Hacer ceros la columna'),disp(i)
for j=1:n
if j~=i
A(j,:) = (A(j,:)*piv - A(i,:)*A(j,i))/pivAnt
end
end

% Guardar el pivote anterior
fprintf(1,'Pivonte Anterior')
pivAnt = piv

end

% Dividir entre el ultimo pivote (determinante)
A = A/piv

% Obtener resultado
resultado = A(:,n+1:m)
determinante = det*piv


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

% Last Modified by GUIDE v2.5 28-Oct-2012 09:27:57

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

% Choose default command line output for Metodo_Montante
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = Metodo_Montante_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;



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


% --- Executes during object creation, after setting all properties.
function matriz_CreateFcn(hObject, eventdata, handles)
% hObject handle to matriz (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 matriz2_Callback(hObject, eventdata, handles)
% hObject handle to matriz2 (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 matriz2 as text
% str2double(get(hObject,'String')) returns contents of matriz2 as a double
matriz2 = str2double(get(hObject,'String'));


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


%Para leer el dato colocado en celsius
A = eval(get(handles.matriz,'string'));
b = eval(get(handles.matriz2,'string'));

%Calcular matriz por el metodo montante
final=montantes(A,b)

%Escribir Datos en matriz
set(handles.resultado,'string',num2str(final));
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder