L3
Click here to load reader
Transcript of L3
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
LABORATORIO Nº 03ESTRUCTURA CONDICIONAL “SWITCH”
OBJETIVO
Conocimiento y dominio de las sentencias if, switch y while, con lectura y escriturainteractiva de variables, que permiten realizar una u otra operación según se cumpla ono una determinada condición.
PROBLEMA Nº O1
Desarrollar un programa de hidraulica de canales abiertos que calcule el tirante normal,area, perímetro, radio hidráulico, velocidad, numero de foude, energía especifica, tipiode flujo, espejo de agua o foco de parábola de flujo de agua por diferentes seccionesgeométricas tales como: Rectangular, Triangular, Trapezoidal, Circular, parabolico,herradura, etc. El programa debe ser elaborado en el Interfaz Grafica de Usuario (GUI) yM-File de MATLAB.. Usted debe controlar todos los objetos y funciones que utilice parael ingreso, procesamiento y presentación de resultados de acuerdo a la selección quehaga el usuario del programa.
CANALES ABIERTOS Y SUS PROPIEDADES
Un canal abierto es un conducto en el cual el agua fluye con una superficie libre. Deacuerdo con su origen un canal puede set natural o artificialLos canales naturales incluyen todos los cursos de agua que existen de manera natural enla Tierra, los cuales varian en tamano desde pequenos arroyuelos en zonas montanosas,hasta quebradas, arroyos, rios pequenos y grandes, y estuarios de mareas. Lascorrientes subterraneas que transportan agua con una superficie libre tambien sonconsideradas como canales abiertos naturales.Las propiedades hidraulicas de un canal natural por lo general son muy irregulares. Enalgunos casos pueden hacerse suposiciones empiricas razonablemente consistentescon las observaciones y experiencias reales, de tal modo que las condiciones de flujoen estos canales se vuelvan manejables mediante el tratamiento analitico de lahidraulica teorica. Un estudio completo sabre el comportamiento del flujo en canalesnaturales requiere el conocimiento de otros campos, como hidrologia, geomorfologia,transporte de sedimentos, etc. Este hecho constituye, un tarea de estudio por si mismo,conocido como hidraulica fluvial.Los canales artificiales son aquellos construidos o desarrollados mediante el esfuerzohumano: canales de navegacion, canales de centrales hidroelectrica s, canales ycanaletas de irrigation, cunetas de drenaje, vertederos, canales de des borde, canaletasde madera, cunetas a lo largo de carreteras, etc., asi como canales de modelosconstruidos en el laboratorio con proposi tos experimentales . Las propiedadeshidraulicas de estos canales pueden ser controladas hasta un nivel deseado o disenadaspara cumplir unos requisitos determinados. La aplicacion de las teorias hidraulicas acanales artificiales produciran, por tanto, resultados bastante similares a las condicionesreales y, por consiguiente, son razonablemente exactos para propositos practicos dediseno.
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
INTERFAZ PRINCIPAL DEL PROGRAMA
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
ESCOGIENDO ALGUNA DE LAS SECCIONES Y EJECUTANDO
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
CÓDIGO DEL ROGRAMA
function varargout = HYCANALES(varargin)gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @HYCANALES_OpeningFcn, ...'gui_OutputFcn', @HYCANALES_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{:});
elsegui_mainfcn(gui_State, varargin{:});
end
function HYCANALES_OpeningFcn(hObject, eventdata, handles, varargin)
scrsz=get(0,'screensize');pa=get(gcf,'position');xr=scrsz(3)-pa(3);
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
xp=round(xr/2);yr=scrsz(4)-pa(4);yp=round(yr/2);set(gcf,'position',[xp yp pa(3) pa(4)]);
img=imread('unsch.jpg');axes(handles.axes1);imshow(img);
img=imread('hcanales.jpg');axes(handles.axes2);imshow(img);
set(handles.tiempo,'string',datestr(now))
handles.output = hObject;guidata(hObject, handles);
function varargout = HYCANALES_OutputFcn(hObject, eventdata, handles)varargout{1} = handles.output;
function caudal_Callback(hObject, eventdata, handles)function caudal_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
function rugosidad_Callback(hObject, eventdata, handles)function rugosidad_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
function pendiente_Callback(hObject, eventdata, handles)function pendiente_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
function talud_Callback(hObject, eventdata, handles)function talud_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
function espejo_Callback(hObject, eventdata, handles)function espejo_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
function diametro_Callback(hObject, eventdata, handles)function diametro_CreateFcn(hObject, eventdata, handles)
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
function base_Callback(hObject, eventdata, handles)function base_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
function seccion_Callback(hObject, eventdata, handles)
global u Q n S
u=get(handles.seccion,'value');Q=str2double(get(handles.caudal,'string'));n=str2double(get(handles.rugosidad,'string'));S=str2double(get(handles.pendiente,'string'));
switch ucase 1
msgbox('Escoja una seccion','ERROR')return
case 2 %Seccion Rectacgularimg=imread('rectangular.jpg');axes(handles.axes2)imshow(img)
set(handles.caudal,'visible','on');set(handles.rugosidad,'visible','on');set(handles.pendiente,'visible','on');set(handles.base,'visible','on');set(handles.talud,'visible','off');set(handles.diametro,'visible','off');set(handles.espejo,'visible','off');set(handles.text1,'visible','on');set(handles.text2,'visible','on');set(handles.text3,'visible','on');set(handles.text4,'visible','on');set(handles.text5,'visible','off');set(handles.text6,'visible','on');set(handles.text7,'visible','on');set(handles.text8,'visible','on');set(handles.text9,'visible','off');set(handles.text10,'visible','off');set(handles.text11,'visible','off');set(handles.text12,'visible','off');
b=str2double(get(handles.base,'string'));z=0;
case 3 %Seccion Triangularimg=imread('triangular.jpg');axes(handles.axes2)imshow(img)
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
set(handles.caudal,'visible','on');set(handles.rugosidad,'visible','on');set(handles.pendiente,'visible','on');set(handles.base,'visible','off');set(handles.talud,'visible','on');set(handles.diametro,'visible','off');set(handles.espejo,'visible','off');set(handles.text1,'visible','on');set(handles.text2,'visible','on');set(handles.text3,'visible','on');set(handles.text4,'visible','off');set(handles.text5,'visible','on');set(handles.text6,'visible','on');set(handles.text7,'visible','on');set(handles.text8,'visible','off');set(handles.text9,'visible','off');set(handles.text10,'visible','off');set(handles.text11,'visible','off');set(handles.text12,'visible','off');
b=0;z=str2double(get(handles.talud,'string'));
case 4 %Seccion Trapezoidalimg=imread('trapezoidal.jpg');axes(handles.axes2)imshow(img)
set(handles.caudal,'visible','on');set(handles.rugosidad,'visible','on');set(handles.pendiente,'visible','on');set(handles.base,'visible','on');set(handles.talud,'visible','on');set(handles.diametro,'visible','off');set(handles.espejo,'visible','off');set(handles.text1,'visible','on');set(handles.text2,'visible','on');set(handles.text3,'visible','on');set(handles.text4,'visible','on');set(handles.text5,'visible','on');set(handles.text6,'visible','on');set(handles.text7,'visible','on');set(handles.text8,'visible','on');set(handles.text9,'visible','off');set(handles.text10,'visible','off');set(handles.text11,'visible','off');set(handles.text12,'visible','off');
b=str2double(get(handles.base,'string'));z=str2double(get(handles.talud,'string'));
case 5 %Seccion Parabolicoimg=imread('parabolico.jpg');axes(handles.axes2)imshow(img)
set(handles.caudal,'visible','on');set(handles.rugosidad,'visible','on');
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
set(handles.pendiente,'visible','on');set(handles.base,'visible','off');set(handles.talud,'visible','off');set(handles.diametro,'visible','off');set(handles.espejo,'visible','on');set(handles.text1,'visible','on');set(handles.text2,'visible','on');set(handles.text3,'visible','on');set(handles.text4,'visible','off');set(handles.text5,'visible','off');set(handles.text6,'visible','on');set(handles.text7,'visible','on');set(handles.text8,'visible','off');set(handles.text9,'visible','on');set(handles.text10,'visible','off');set(handles.text11,'visible','on');set(handles.text12,'visible','off');
T=str2double(get(handles.espejo,'string'));
case 6 %Seccion Circularimg=imread('circular.jpg');axes(handles.axes2)imshow(img)
set(handles.caudal,'visible','on');set(handles.rugosidad,'visible','on');set(handles.pendiente,'visible','on');set(handles.base,'visible','off');set(handles.talud,'visible','off');set(handles.diametro,'visible','on');set(handles.espejo,'visible','off');set(handles.text1,'visible','on');set(handles.text2,'visible','on');set(handles.text3,'visible','on');set(handles.text4,'visible','off');set(handles.text5,'visible','off');set(handles.text6,'visible','on');set(handles.text7,'visible','on');set(handles.text8,'visible','of');set(handles.text9,'visible','off');set(handles.text10,'visible','on');set(handles.text11,'visible','off');set(handles.text12,'visible','on');
D=str2double(get(handles.diametro,'string'));end
function seccion_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');end
function ejecutar_Callback(hObject, eventdata, handles)
global u Q n S
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
switch ucase 1
errordlg('Escoja una seccion','ERROR')return
case 2 %Seccion Rectacgularb=str2double(get(handles.base,'string'));z=0;
case 3 %Seccion Triangularb=0;z=str2double(get(handles.talud,'string'));
case 4 %Seccion Trapezoidalb=str2double(get(handles.base,'string'));z=str2double(get(handles.talud,'string'));
case 5 %Seccion ParabolicoT=str2double(get(handles.espejo,'string'));
case 6 %Seccion CircularD=str2double(get(handles.diametro,'string'));
end
% Proceso de caluloerror=0.0000000001C=((Q*n)/sqrt(S))^3;y=1;if u<=4
L=sqrt(1+z^2);E=1;while E>=error
G=y;J=C*(b+2*y*L)^2;K=(b+z*y)^5;y=(J/K)^(1/5);E=abs(G-y);
endA=(b+z*y)*y;P=b+2*y*L;T=b+2*z*y;
elseif u==5E=1;while E>=error
G=y;J=C*(3/(2*T))^5;K=(T^2)/(8*y);P=(2*K*y+4*y^2)^0.5+K*log(((K+2*y)^0.5+(2*y)^0.5)/(K^0.5));y=(J*P^2)^(1/5);E=abs(G-y);
endA=(2*T*y)/3;P=(2*K*y+4*y^2)^0.5+K*log(((K+2*y)^0.5+(2*y)^0.5)/(K^0.5));K=(T^2)/(8*y);
else u==6E=1;teta=pi/2;while E>=error
G=teta;J=(D*teta/2)^2;K=8*((C*J)^(1/5))/(D^2);
UNIVERSIDAD NACIONAL DE SAN CRISTOBAL DE HUAMANGA - UNSCHFACULTAD : INGENIERIA DE MINAS, GEOLOGIA Y CIVILESCUELAASIGNATURA
: INGENIERIA CIVIL: PROGRAMACION DIGITAL (IC-244)
PROFESOR:ING. CRISTIAN CASTRO PEREZ
FECHALUGAR
: 08/06/2009: AYACUCHO-PERÚ
JEFE DE PRÁCTICAS:CÉSAR LIFONZO SALCEDO
E-mail: [email protected] E-mail: [email protected] Web page: http://www.unsch.edu.pe
teta=sin(teta)+K;E=abs(G-teta);
endy=D*(1-cos(teta/2))/2;A=((D^2)*(teta-sin(teta)))/8;P=(teta*D)/2;T=D*sin(teta/2);
end
R=A/P;V=Q/A;F=V/(sqrt(9.810001*A/T));E=y+V^2/19.62;
% Visualizacion de Resultadosset(handles.tirante,'string',y);set(handles.velocidad,'string',V);set(handles.area,'string',A);set(handles.perimetro,'string',P);set(handles.radio,'string',R);set(handles.froude,'string',F);set(handles.energia,'string',E);
if u==5set(handles.respejo,'string',K);set(handles.text18,'string','Foco de la Parabola');
elseset(handles.respejo,'string',T);set(handles.text18,'string','Espejo del agua');
end
if F<1set(handles.flujo,'string','Subcritico');
elseset(handles.flujo,'string','Supercritico');
end
function ayuda_Callback(hObject, eventdata, handles)
helpdlg('Primero debera escoger la seccion del canal y luego ingresar losdatos que se pide de acuerdo al tipo de seccion, no ejecute el programa sinantes haber ingresado los datos. EL AUTOR ','AYUDA')
function salir_Callback(hObject, eventdata, handles)
exit