Sei sulla pagina 1di 7

7/13/14 11:44 AM D:\SedimentTransport.

m 1 of 7
function varargout = SedimentTransport(varargin)
% SEDIMENTTRANSPORT MATLAB code for SedimentTransport.fig
% SEDIMENTTRANSPORT, by itself, creates a new SEDIMENTTRANSPORT or raises the
existing
% singleton*.
%
% H = SEDIMENTTRANSPORT returns the handle to a new SEDIMENTTRANSPORT or the handle
to
% the existing singleton*.
%
% SEDIMENTTRANSPORT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SEDIMENTTRANSPORT.M with the given input arguments.
%
% SEDIMENTTRANSPORT('Property','Value',...) creates a new SEDIMENTTRANSPORT or
raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before SedimentTransport_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to SedimentTransport_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 SedimentTransport
% Last Modified by GUIDE v2.5 10-Jul-2014 09:08:50
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @SedimentTransport_OpeningFcn, ...
'gui_OutputFcn', @SedimentTransport_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 SedimentTransport is made visible.
function SedimentTransport_OpeningFcn(hObject, eventdata, handles, varargin)
7/13/14 11:44 AM D:\SedimentTransport.m 2 of 7
% 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 SedimentTransport (see VARARGIN)
% Choose default command line output for SedimentTransport
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes SedimentTransport wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = SedimentTransport_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;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MENU ARCHIVO %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --------------------------------------------------------------------
function Archivo_Callback(hObject, eventdata, handles)
% hObject handle to Archivo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Nuevo_Callback(hObject, eventdata, handles)
% hObject handle to Nuevo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Abrir_Callback(hObject, eventdata, handles)
% hObject handle to Abrir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
7/13/14 11:44 AM D:\SedimentTransport.m 3 of 7
LeerDatos(handles);
% --------------------------------------------------------------------
function Guardar_Callback(hObject, eventdata, handles)
% hObject handle to Guardar (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function GuardarComo_Callback(hObject, eventdata, handles)
% hObject handle to GuardarComo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Salir_Callback(hObject, eventdata, handles)
% hObject handle to Salir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CONTROLES ADICIONALES %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell
array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
global P X H Cr Cl
% La progresiva seleccionada en el control popupmenu1
k=get(handles.popupmenu1,'Value');
%yy=get(hObject,'Value')
% Las ordenadas (H) para la progresiva seleccionada
h=H(:,k);
% Graficar
set(handles.axes1,'NextPlot', 'Replace');
plot(X,h,'-o');
title(strcat('Progresiva: ', num2str(P(k))));
7/13/14 11:44 AM D:\SedimentTransport.m 4 of 7
axis normal;
grid on;
% Coeficientes de manning
set(handles.edit1,'String',Cl(k));
set(handles.edit2,'String',Cr(k));
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
7/13/14 11:44 AM D:\SedimentTransport.m 5 of 7
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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 selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell
array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
global Tr D Qh
% La progresiva seleccionada en el control popupmenu1
k=get(handles.popupmenu2,'Value');
%yy=get(hObject,'Value')
% Los caudales para el Tr seleccionado
q=Qh(:,k);
% Graficar
set(handles.axes1,'NextPlot', 'Replace');
plot(D,q,'-o');
title(strcat('Tiempo de Retorno: ', num2str(Tr(k))));
axis normal;
grid on;
% Coeficientes de manning
%set(handles.edit1,'String',Cl(k));
%set(handles.edit2,'String',Cr(k));
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
7/13/14 11:44 AM D:\SedimentTransport.m 6 of 7
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FUNCTIONS %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function LeerDatos(handles)
% Variables Globales
global P X H Cr Cl Tr D Qh
% Lectura de la direccin y nombre del archivo excel
[filename, pathname] = ...
uigetfile({...
'*.xlsx','Microsoft Excel Files (*.xlsx)' ;...
'*.xls','Microsoft Excel Files (*.xls)' ;...
'*.*', 'All Files (*.*)'},...
'File Selector');
% Verificar si un archivo fue seleccionado
if filename ~= 0
% Direccin completa al archivo selecionado
direccion=strcat(pathname, filename);
% Hoja 1
% Lectura de los datos del archivo excel
num = xlsread(direccion,1);
[m,n]=size(num);
% P: Progresivas, X: distancia izquierda derecha, H: alturas,
% Coeficiente de manning: Cr Cl
P=num(1,2:n); % Progresiva
Cr=num(2,2:n); % C margen derecho
Cl=num(3,2:n); % C margen izquierdo
X=num(6:m,1);
H=num(6:m,2:n);
% Carga las progresivas a un popupmenu1
b=mat2cell(P,1);
set(handles.popupmenu1,'String',b);
% Hoja 2
% Lectura de los datos del archivo excel
num = xlsread(direccion,2);
[m,n]=size(num);
% Tr: tiempo de retorno, D: duracin(horas), Qh: caudales del
% hidrograma
7/13/14 11:44 AM D:\SedimentTransport.m 7 of 7
Tr=num(1,2:n);
D=num(2:m,1);
Qh=num(2:m,2:n);
% Carga las progresivas a un popupmenu2
b=mat2cell(Tr,1);
set(handles.popupmenu2,'String',b);
end
function A=CoordinateSurface(M)
% Function description
% Input: M is array m*n, coordinates polygon
% Output: A surface polygon
% Aadiendo la primera coordenada al final
M=[M;M(1,:)];
% Tamao de la matriz
[m,n]=size(M);
% Variables
A=0; D=0; I=0;
% Clculo de la superficie
for k=1:(m-1)
% Valores D
d1=M(k,1); d2=M(k+1,2);
D=D+d1*d2;
% valores I
i1=M(k,2); i2=M(k+1,1);
I=I+i1*i2;
end
% La superficie valor de retorno
A=1/2*abs(D-I);

Potrebbero piacerti anche