function varargout = CES(varargin)
%PROGRAMA QUE CALCULA LA PRDIDA DE TRANSMISIN DE UNA CMARA DE EXPANSIN
%SIMPLE,DEPENDE DE LA VENTANA PRINCIPAL MUFFLERS
% Last Modified by GUIDE v2.5 30-Sep-2009 01:30:00
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @CES_OpeningFcn, ...
'gui_OutputFcn', @CES_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 CES is made visible.
function CES_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 CES (see VARARGIN)
% Choose default command line output for CES
handles.output = hObject;
% CARGANDO DATOS DE LA VENTANA PRINCIPAL
global t RHO Q indicador;
%CENTRAR VENTANA
scrsz = get(0,'ScreenSize');
pos_act=get(handles.CES,'Position');
xr=scrsz(3) - pos_act(3);
xp=round(xr/2);
yr=scrsz(4) - pos_act(4);
yp=round(yr/2);
set(handles.CES,'Position',[xp yp pos_act(3) pos_act(4)]);
% CARGAR FIGURA PARA INGRESO DE DATOS
axes(handles.axes1)
background = imread('CEScotas.jpg');
axis off;
imshow(background);
if (indicador==2 & exist('t2.mat'))
load t2
% DIAMETRO CONDUCTO DE ENTRADA EN MM
set(handles.edit1,'string',D1/10^-3)
set(handles.text2,'string',D1/10^-3)
% DIAMETRO DE LA CMARA EN MM
set(handles.edit2,'string',D2/10^-3)
% LONGITUD DE LA CMARA EN MM
set(handles.edit3,'string',L/10^-3)
c=331*sqrt((t+273)/273);
Si=(pi*(D1)^2)/4; %Superficie transversal del conducto de entrada
Sii=(pi*(D2)^2)/4; %Superficie transversal de la cmara
f=0:4000; % Matriz de Frecuencias
for aux=1:length(f);
%MATRICES DE TRANSFERENCIA
% Expansin Abrupta
Zd=(RHO*c)/Sii;
V=Q/Sii;% Velocidad de flujo medio a travs de Sii
Mi=V/c;% Nmero de Mach en la Cmara
K=((Sii/Si)-1)^2;
Ti=[1 K*Mi*Zd;0 1];
%Conducto Simple
kc=((2*pi*f(aux))/c)/(1-Mi^2);
Tii=exp(-j*Mi*kc*L)*[cos(kc*L) j*Zd*sin(kc*L);(j/Zd)*sin(kc*L) cos(kc*L)];
% Contraccion Abrupta
K=(1-Si/Sii)/2;
Zd=(RHO*c)/Si;
V=Q/Si;% Velocidad de flujo medio a travs de Si
Mi=V/c;% Nmero de Mach en la salida
Tiii=[1 K*Mi*Zd;0 1];
% MATRIZ TOTAL
TCE=Ti*Tii*Tiii;
TL(aux)=20*log10((1/2)*abs(TCE(1,1)+((Si/(RHO*c))*TCE(1,2))+(((RHO*c)/Si)*TCE(2,1))+TCE(2,2)));
end
axes(handles.axes2)
fc=find(f==round((1.84*c)/(pi*D2)));
fnew=f(1,1:fc);
plot(fnew,TL(1:length(fnew)),'r')
xlabel('Frecuencia (Hz)','FontName','Lucida Console');
ylabel('TL (dB)','FontName','Lucida Console');
grid on;
handles.D1=D1;
handles.D2=D2;
handles.L=L;
elseif (indicador==1 & exist('t1.mat'))
load t1
% DIAMETRO CONDUCTO DE ENTRADA EN MM
set(handles.edit1,'string',D1/10^-3)
set(handles.text2,'string',D1/10^-3)
% DIAMETRO DE LA CMARA EN MM
set(handles.edit2,'string',D2/10^-3)
% LONGITUD DE LA CMARA EN MM
set(handles.edit3,'string',L/10^-3)
c=331*sqrt((t+273)/273);
Si=(pi*(D1)^2)/4; %Superficie transversal del conducto de entrada
Sii=(pi*(D2)^2)/4; %Superficie transversal de la cmara
f=0:4000; % Matriz de Frecuencias
for aux=1:length(f);
%MATRICES DE TRANSFERENCIA
% Expansin Abrupta
Zd=(RHO*c)/Sii;
V=Q/Sii;% Velocidad de flujo medio a travs de Sii
Mi=V/c;% Nmero de Mach en la Cmara
K=((Sii/Si)-1)^2;
Ti=[1 K*Mi*Zd;0 1];
%Conducto Simple
kc=((2*pi*f(aux))/c)/(1-Mi^2);
Tii=exp(-j*Mi*kc*L)*[cos(kc*L) j*Zd*sin(kc*L);(j/Zd)*sin(kc*L) cos(kc*L)];
% Contraccion Abrupta
K=(1-Si/Sii)/2;
Zd=(RHO*c)/Si;
V=Q/Si;% Velocidad de flujo medio a travs de Si
Mi=V/c;% Nmero de Mach en la salida
Tiii=[1 K*Mi*Zd;0 1];
% MATRIZ TOTAL
TCE=Ti*Tii*Tiii;
TL(aux)=20*log10((1/2)*abs(TCE(1,1)+((Si/(RHO*c))*TCE(1,2))+(((RHO*c)/Si)*TCE(2,1))+TCE(2,2)));
end
axes(handles.axes2)
fc=find(f==round((1.84*c)/(pi*D2)));
fnew=f(1,1:fc);
plot(fnew,TL(1:length(fnew)),'r')
xlabel('Frecuencia (Hz)','FontName','Lucida Console');
ylabel('TL (dB)','FontName','Lucida Console');
grid on;
handles.D1=D1;
handles.D2=D2;
handles.L=L;
else
% CALCULO VELOCIDAD DEL SONIDO EN FUNCION DE LA TEMPERATURA
c=331*sqrt((t+273)/273);
% VARIABLES Y CALCULO INICIAL DEL PROGRAMA
handles.d1=38.1; % DIAMETRO CONDUCTO DE ENTRADA EN MM
set(handles.edit1,'string',handles.d1)
set(handles.text2,'string',handles.d1)
handles.d2=155.7;% DIAMETRO DE LA CMARA EN MM
set(handles.edit2,'string',handles.d2)
handles.l=195;% LONGITUD DE LA CMARA EN MM
set(handles.edit3,'string',handles.l)
%% Clculos Bsicos
handles.D1=handles.d1*10^-3;
handles.D2=handles.d2*10^-3;
Si=(pi*(handles.D1)^2)/4; %Superficie transversal del conducto de entrada
Sii=(pi*(handles.D2)^2)/4; %Superficie transversal de la cmara
%% Clculos TL en presencia de flujo
handles.L=handles.l*10^-3;
f=0:4000; % Matriz de Frecuencias
for aux=1:length(f);
%MATRICES DE TRANSFERENCIA
% Expansin Abrupta
Zd=(RHO*c)/Sii;
V=Q/Sii;% Velocidad de flujo medio a travs de Sii
Mi=V/c;% Nmero de Mach en la Cmara
K=((Sii/Si)-1)^2;
Ti=[1 K*Mi*Zd;0 1];
%Conducto Simple
kc=((2*pi*f(aux))/c)/(1-Mi^2);
Tii=exp(-j*Mi*kc*handles.L)*[cos(kc*handles.L) j*Zd*sin(kc*handles.L);(j/Zd)*sin(kc*handles.L) cos(kc*handles.L)];
% Contraccion Abrupta
K=(1-Si/Sii)/2;
Zd=(RHO*c)/Si;
V=Q/Si;% Velocidad de flujo medio a travs de Si
Mi=V/c;% Nmero de Mach en la salida
Tiii=[1 K*Mi*Zd;0 1];
% MATRIZ TOTAL
TCE=Ti*Tii*Tiii;
MTCE(aux)={TCE};
TL(aux)=20*log10((1/2)*abs(TCE(1,1)+((Si/(RHO*c))*TCE(1,2))+(((RHO*c)/Si)*TCE(2,1))+TCE(2,2)));
end
axes(handles.axes2)
fc=find(f==round((1.84*c)/(pi*handles.D2)));
fnew=f(1,1:fc);
plot(fnew,TL(1:length(fnew)),'r');
xlabel('Frecuencia (Hz)','FontName','Lucida Console');
ylabel('TL (dB)','FontName','Lucida Console');
grid on;
if indicador==1
handles.S1D1=handles.D1;
handles.S1D2=handles.D2;
handles.S1L=handles.L;
handles.nombre1='CAMARA DE EXPANSIN SIMPLE';
save guardar1.mat -struct handles;
T1=MTCE;
S1=Si;
save Matriz1 T1 S1
elseif indicador==2
handles.S2D1=handles.D1;
handles.S2D2=handles.D2;
handles.S2L=handles.L;
handles.nombre2='CAMARA DE EXPANSIN SIMPLE';
save guardar2.mat -struct handles;
S3=Si;
T2=MTCE;
save Matriz2 T2 S3
end
end
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes CES wait for user response (see UIRESUME)
% uiwait(handles.CES);
% --- Outputs from this function are returned to the command line.
function varargout = CES_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 edit1_Callback(hObject, eventdata, handles)
%ENTRADA DIAMETRO CONDUCTO ENTRADA EN MM
handles=guidata(gcbo);
handles.D1=str2double(get(hObject,'String'));
set(handles.text2,'string',handles.D1);
handles.D1=handles.D1*10^-3;
if isnan(handles.D1)
errordlg('Debes ingresar un valor nmerico', 'Mala Entrada', 'modal')
set(hObject,'string',handles.d1);
set(handles.text2,'string',handles.d1);
handles.D1=handles.d1;
handles.D1=handles.D1*10^-3;
end
if handles.D1<=0
errordlg('Debes ingresar un valor positivo', 'Mala entrada', 'modal')
set(hObject,'string',handles.d1);
set(handles.text2,'string',handles.d1);
handles.D1=handles.d1;
handles.D1=handles.D1*10^-3;
end
guidata(gcbo,handles)
% --- 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)
handles=guidata(gcbo);
handles.D2=str2double(get(hObject,'String'));
handles.D2=handles.D2*10^-3;
if isnan(handles.D2)
errordlg('Debes ingresar un valor nmerico', 'Mala Entrada', 'modal')
set(hObject,'string',handles.d2);
handles.D2=handles.d2;
handles.D2=handles.D2*10^-3;
return
end
if handles.D2<=0
errordlg('Debes ingresar un valor positivo', 'Mala entrada', 'modal')
set(hObject,'string',handles.d2);
handles.D2=handles.d2;
handles.D2=handles.D2*10^-3;
return
end
guidata(gcbo,handles)
% --- 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
function edit3_Callback(hObject, eventdata, handles)
handles=guidata(gcbo);
%ENTRADA LONGITUD EN MM
handles.L=str2double(get(hObject,'String'));
handles.L=handles.L*10^-3;
if isnan(handles.L)
errordlg('Debes ingresar un valor nmerico', 'Mala Entrada', 'modal')
set(hObject,'string',handles.l);
handles.L=handles.l;
handles.L=handles.L*10^-3;
return
end
if handles.L<=0
errordlg('Debes ingresar un valor positivo', 'Mala entrada', 'modal')
set(hObject,'string',handles.l);
handles.L=handles.l;
handles.L=handles.L*10^-3;
return
end
guidata(gcbo,handles)
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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)
handles=guidata(gcbo);
global t RHO Q indicador;
%BOTON CALCULAR
if handles.D2>handles.D1
%% Clculos Bsicos
c=331*sqrt((t+273)/273);
Si=(pi*(handles.D1)^2)/4; %Superficie transversal del conducto de entrada
Sii=(pi*(handles.D2)^2)/4; %Superficie transversal de la cmara
%% Clculos TL en presencia de flujo
f=0:4000; % Matriz de Frecuencias
for aux=1:length(f);
%MATRICES DE TRANSFERENCIA
% Expansin Abrupta
Zd=(RHO*c)/Sii;
V=Q/Sii;% Velocidad de flujo medio a travs de Sii
Mi=V/c;% Nmero de Mach en la Cmara
K=((Sii/Si)-1)^2;
Ti=[1 K*Mi*Zd;0 1];
%Conducto Simple
kc=((2*pi*f(aux))/c)/(1-Mi^2);
Tii=exp(-j*Mi*kc*handles.L)*[cos(kc*handles.L) j*Zd*sin(kc*handles.L);(j/Zd)*sin(kc*handles.L) cos(kc*handles.L)];
% Contraccion Abrupta
K=(1-Si/Sii)/2;
Zd=(RHO*c)/Si;
V=Q/Si;% Velocidad de flujo medio a travs de Si
Mi=V/c;% Nmero de Mach en la salida
Tiii=[1 K*Mi*Zd;0 1];
% MATRIZ TOTAL
TCE=Ti*Tii*Tiii;
MTCE(aux)={TCE};
TL(aux)=20*log10((1/2)*abs(TCE(1,1)+((Si/(RHO*c))*TCE(1,2))+(((RHO*c)/Si)*TCE(2,1))+TCE(2,2)));
end
axes(handles.axes2)
fc=find(f==round((1.84*c)/(pi*handles.D2)));
fnew=f(1,1:fc);
plot(fnew,TL(1:length(fnew)),'r')
xlabel('Frecuencia (Hz)','FontName','Lucida Console');
ylabel('TL (dB)','FontName','Lucida Console');
grid on;
if indicador==1
handles.S1D1=handles.D1;
handles.S1D2=handles.D2;
handles.S1L=handles.L;
handles.nombre1='CAMARA DE EXPANSIN SIMPLE';
save guardar1.mat -struct handles;
S1=Si;
T1=MTCE;
save Matriz1 T1 S1
save t1.mat -struct handles;
elseif indicador==2
handles.S2D1=handles.D1;
handles.S2D2=handles.D2;
handles.S2L=handles.L;
handles.nombre2='CAMARA DE EXPANSIN SIMPLE';
save guardar2.mat -struct handles;
S3=Si;
T2=MTCE;
save Matriz2 T2 S3
save t2.mat -struct handles;
end
else
errordlg('El dimetro del Conducto debe ser menor que el dimetro de la Cmara','Entrada Errnea', 'modal')
return
end