Code covered by the BSD License  

Highlights from
AKUZOFT ACOUSTIC SOFTWARE

image thumbnail
from AKUZOFT ACOUSTIC SOFTWARE by Marco Araos
zip file with: Akuzoft archives Manual Akuzoft

mufflers(varargin)
function varargout = mufflers(varargin)
% PROGRAMA QUE CALCULA LA PRDIDA DE TRANSMISIN SONORA DE TRES TIPO DE
% SILENCIADORES REACTIVOS, ADEMS DE CALCULAR LA PRDIDA DE TRANSMISIN
% SONORA TOTAL DE LAS COMBINACIONES DE ELLOS.

%ESTE PROGRAMA UTILIZA MATRICES DE TRANSFERENCIAS PARA SUS CLCULOS Y HA
%SIDO VALIDADO A TRAVS DE REPORTES DE MEDICIN DE ESTOS TIPOS DE
%SILENCIADORES ENCONTRADOS EN LA BIBLIOGRAFA.

%DISEADO POR MARCO ARAOS BARRIA COMO PARTE DE SU TRABAJO DE GRADO DE LA
%UNIVERSIDAD AUSTRAL DE CHILE, CORREO: maaraos@gmail.com


% Last Modified by GUIDE v2.5 04-Oct-2009 19:45:25

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @mufflers_OpeningFcn, ...
                   'gui_OutputFcn',  @mufflers_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 mufflers is made visible.
function mufflers_OpeningFcn(hObject, eventdata, handles, varargin)

warning('off')
clc;
clear global;

% 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 mufflers (see VARARGIN)

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

if exist('t1.mat')
    delete('t1.mat')
end

if exist('t2.mat')
    delete('t2.mat')
end

if exist('Matriz1.mat')
    delete('Matriz1.mat')
end

if exist('Matriz2.mat')
    delete('Matriz2.mat')
end

if exist('guardar1.mat')
    delete('guardar1.mat')
end

if exist('guardar2.mat')
    delete('guardar2.mat')
end

%CENTRAR VENTANA PRINCIPAL

scrsz = get(0,'ScreenSize');
pos_act=get(handles.figure1,'Position');
xr=scrsz(3) - pos_act(3);
xp=round(xr/2);
yr=scrsz(4) - pos_act(4);
yp=round(yr/2);
set(handles.figure1,'Position',[xp yp pos_act(3) pos_act(4)]);

% COLOCAR IMAGENES EN BOTONES CORRESPONDIENTES

[a]=imread('nuevasesion.jpg');
[r,c]=size(a);
x=ceil(r/30);
y=ceil(c/100);
g=a(1:x:end,1:y:end,:);
g(g==255)=5.5*255;
set(handles.pushbutton1,'CData',g);

[a]=imread('guardar.jpg');
[r,c]=size(a);
x=ceil(r/30);
y=ceil(c/100);
g=a(1:x:end,1:y:end,:);
g(g==255)=5.5*255;
set(handles.pushbutton2,'CData',g);

[a]=imread('Borrar.jpg');
[r,c]=size(a);
x=ceil(r/30);
y=ceil(c/100);
g=a(1:x:end,1:y:end,:);
g(g==255)=5.5*255;
set(handles.pushbutton10,'CData',g);

[a]=imread('ayuda.jpg');
[r,c]=size(a);
x=ceil(r/30);
y=ceil(c/100);
g=a(1:x:end,1:y:end,:);
g(g==255)=5.5*255;
set(handles.pushbutton6,'CData',g);


[a]=imread('CE1.jpg');
[r,c]=size(a);
x=ceil(r/30);
y=ceil(c/300);
g=a(1:x:end,1:y:end,:);
g(g==255)=5.5*255;
set(handles.pushbutton3,'CData',g);


[a]=imread('CEXT.jpg');
[r,c]=size(a);
x=ceil(r/30);
y=ceil(c/300);
g=a(1:x:end,1:y:end,:);
g(g==255)=5.5*255;
set(handles.pushbutton4,'CData',g);


[a]=imread('RESC.jpg');
[r,c]=size(a);
x=ceil(r/30);
y=ceil(c/300);
g=a(1:x:end,1:y:end,:);
g(g==255)=5.5*255;
set(handles.pushbutton5,'CData',g);



% COLOCAR IMAGEN EN LOS EJES PRINCIPALES

r=zeros(1,4000);
f=1:4000;
axes(handles.axes1)
plot(f,r)
set(gca,'ylim',[0 100])
xlabel('Frecuencia (Hz)','FontName','Lucida Console','Fontweight','bold');
ylabel('TL (dB)','FontName','Lucida Console','Fontweight','bold');
grid on







%% VALORES INICIALES DEL PROGRAMA

global t RHO Q;

t=17.5 ;% TEMPERATURA DEL GAS EN C.
set(handles.edit1,'string',t);

RHO=1.18 ;% DENSIDAD DEL GAS EN KG/M3
set(handles.edit2,'string',RHO);

Q=0.13; % VOLUMEN DE FLUJO EN M3/S EN EL CONDUCTO DE ENTRADA

set(handles.edit3,'string',Q);




% Update handles structure
guidata(hObject, handles);

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


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


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)

%BOTON NUEVA SESION

handles=guidata(gcbo);

clc;
clear global;

if exist('t1.mat')
    delete('t1.mat')
end

if exist('t2.mat')
    delete('t2.mat')
end

if exist('Matriz1.mat')
    delete('Matriz1.mat')
end

if exist('Matriz2.mat')
    delete('Matriz2.mat')
end

% limpiando TL dB a los static text correspondiente
    set(handles.text7,'string',''); %63 Hz
    set(handles.text8,'string','');  % 80 Hz
    set(handles.text9,'string','');  % 100 Hz
    set(handles.text10,'string',''); % 125 Hz
    set(handles.text11,'string','');   %160 Hz
    set(handles.text12,'string','');  % 200HZ
    set(handles.text13,'string',''); %250 Hz
    set(handles.text14,'string','');    %315 Hz
    set(handles.text15,'string','');  %400 Hz
    set(handles.text16,'string','');   %500 Hz 
    set(handles.text17,'string','');      % 630 Hz
    set(handles.text18,'string',''); %800 Hz
    set(handles.text19,'string',''); %1000 Hz
    set(handles.text20,'string',''); %1250 Hz
    set(handles.text21,'string','');    % 1600 Hz
    set(handles.text22,'string','');   %2000 Hz
    set(handles.text23,'string','');     %2500 Hz
    set(handles.text24,'string','');    %3150 Hz
    set(handles.text25,'string','');   %4000 Hz



% COLOCAR IMAGEN EN LOS EJES PRINCIPALES

r=zeros(1,4000);
f=1:4000;
axes(handles.axes1)
plot(f,r)
set(gca,'ylim',[0 100])
xlabel('Frecuencia (Hz)','FontName','Lucida Console','Fontweight','bold');
ylabel('TL (dB)','FontName','Lucida Console','Fontweight','bold');
grid on


set(handles.t1,'visible','off');
set(handles.t2,'visible','off');

global t RHO Q ;

t=17.5 ;% TEMPERATURA DEL GAS EN C.
set(handles.edit1,'string',t);

RHO=1.18 ;% DENSIDAD DEL GAS EN KG/M3
set(handles.edit2,'string',RHO);

Q=0.13; % VOLUMEN DE FLUJO EN M3/S EN EL CONDUCTO DE ENTRADA

set(handles.edit3,'string',Q);

set(handles.pushbutton11,'enable','off')


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)

% BOTON GUARDAR

global TLterc BT t RHO Q;

load guardar1.mat
load guardar2.mat



    
  
handles=guidata(gcbo);

val = get(handles.popupmenu1,'Value');


    
if val==2 % Panel de Tercios de Octava
 
    [filename,pathname]=uiputfile({'*.txt'},'Guardar datos como');

% Si se cancela el guardar

if isequal([filename,pathname],[0,0]) 

return

else

archivo=fullfile(pathname,filename);

end


fi = fopen(archivo, 'wt') ;

PT=[BT';round(TLterc)];


fprintf(fi,'%s\n\n\n',char('CONDICIONES INICIALES '));
fprintf(fi,'TEMPERATURA DEL GAS: %6.2f \n',t);
fprintf(fi,'DENSIDAD DEL GAS: %6.2f \n',RHO);
fprintf(fi,'FLUJO VOLUMETRICO: %6.2f \n\n\n',Q);


fprintf(fi,'%s\n\n\n',char('DATOS SILENCIADOR I: '));

if strcmp(nombre1,'CAMARA DE EXPANSIN SIMPLE')

fprintf(fi,'%s\n\n',nombre1);
fprintf(fi,'El Dimetro del Conducto de Entrada es: %6.2f mm\n',S1D1/10^-3);
fprintf(fi,'El Dimetro del Conducto de Salida es: %6.2f mm\n',S1D1/10^-3);
fprintf(fi,'El Dimetro de la Cmara es: %6.2f mm\n',S1D2/10^-3);
fprintf(fi,'La Longitud de la Cmara es: %6.2f mm\n\n\n',S1L/10^-3);


elseif strcmp(nombre1,'CAMARA CON CONDUCTO EXTENDIDO EN LA ENTRADA')

    
    fprintf(fi,'%s\n\n',nombre1);
    fprintf(fi,'El Dimetro del Conducto de Entrada es: %6.2f mm\n',S1DD/10^-3);
    fprintf(fi,'El Dimetro del Conducto de Salida es: %6.2f mm\n',S1DD/10^-3);
    fprintf(fi,'El Dimetro de la Cmara es: %6.2f mm\n',S1DC/10^-3);
    fprintf(fi,'La Longitud del Conducto Extendido: %6.2f mm\n',S1LI/10^-3);
    fprintf(fi,'La Longitud de la Cmara es: %6.2f mm\n\n\n',S1LC/10^-3);

         
elseif strcmp(nombre1,'CAMARA CON RESONADOR CONCENTRICO')

    
    fprintf(fi,'%s\n\n',nombre1);
    fprintf(fi,'El Dimetro del Conducto de Entrada es: %6.2f mm\n',S1RDD/10^-3);
    fprintf(fi,'El Dimetro del Conducto de Salida es: %6.2f mm\n',S1RDD/10^-3);
    fprintf(fi,'El Dimetro de la Cmara es: %6.2f mm\n',S1RDC/10^-3);
    fprintf(fi,'Longitud desde el comienzo de la cmara hasta donde se encuentran los orificios: %6.2f mm\n',S1RLU/10^-3);
    fprintf(fi,'Longitud desde el final de la cmara hasta donde se encuentran los orificios: %6.2f mm\n',S1RLD/10^-3);
    fprintf(fi,'El Dimetro de los orificios es: %6.2f mm\n',S1RDH/10^-3);
    fprintf(fi,'El Espesor del Conducto es: %6.2f mm\n',S1RTW/10^-3);
    fprintf(fi,'El Nmero de  Orificios es: %6.2f \n\n\n',S1RNh);
    
    
    
end


fprintf(fi,'%s\n\n\n',char('DATOS SILENCIADOR II: '));

if strcmp(nombre2,'CAMARA DE EXPANSIN SIMPLE')

fprintf(fi,'%s\n\n',nombre2);
fprintf(fi,'El Dimetro del Conducto de Entrada es: %6.2f mm\n',S2D1/10^-3);
fprintf(fi,'El Dimetro del Conducto de Salida es: %6.2f mm\n',S2D1/10^-3);
fprintf(fi,'El Dimetro de la Cmara es: %6.2f mm\n',S2D2/10^-3);
fprintf(fi,'La Longitud de la Cmara es: %6.2f mm\n\n\n',S2L/10^-3);


elseif strcmp(nombre2,'CAMARA CON CONDUCTO EXTENDIDO EN LA ENTRADA')

    
    fprintf(fi,'%s\n\n',nombre2);
    fprintf(fi,'El Dimetro del Conducto de Entrada es: %6.2f mm\n',S2DD/10^-3);
    fprintf(fi,'El Dimetro del Conducto de Salida es: %6.2f mm\n',S2DD/10^-3);
    fprintf(fi,'El Dimetro de la Cmara es: %6.2f mm\n',S2DC/10^-3);
    fprintf(fi,'La Longitud del Conducto Extendido: %6.2f mm\n',S2LI/10^-3);
    fprintf(fi,'La Longitud de la Cmara es: %6.2f mm\n\n\n',S2LC/10^-3);

         
elseif strcmp(nombre2,'CAMARA CON RESONADOR CONCENTRICO')

    
    fprintf(fi,'%s\n\n',nombre2);
    fprintf(fi,'El Dimetro del Conducto de Entrada es: %6.2f mm\n',S2RDD/10^-3);
    fprintf(fi,'El Dimetro del Conducto de Salida es: %6.2f mm\n',S2RDD/10^-3);
    fprintf(fi,'El Dimetro de la Cmara es: %6.2f mm\n',S2RDC/10^-3);
    fprintf(fi,'Longitud desde el comienzo de la cmara hasta donde se encuentran los orificios: %6.2f mm\n',S2RLU/10^-3);
    fprintf(fi,'Longitud desde el final de la cmara hasta donde se encuentran los orificios: %6.2f mm\n',S2RLD/10^-3);
    fprintf(fi,'El Dimetro de los orificios es: %6.2f mm\n',S2RDH/10^-3);
    fprintf(fi,'El Espesor del Conducto es: %6.2f mm\n',S2RTW/10^-3);
    fprintf(fi,'El Nmero de  Orificios es: %6.2f \n\n\n',S2RNh);
    
    
    
end


fprintf(fi,'%s\n\n\n',char('PERDIDA DE TRANSMISIN DE LA COMBINACIN DE AMBOS SILENCIADORES: '));

fprintf(fi,'%6.f %6.f\n',PT);

 fclose(fi);

end



% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)

% SELECCION CMARA DE EXPANSIN SIMPLE

 % Se Obtiene la propiedad Visible de los Pushbutton donde va la combinacin de silenciadores  
    
    viv=get(handles.t1,'visible');
    vv=get(handles.t2,'visible');

 % Matrices para comparar con los valores obtenidos 
    
    offtotal=char('off','off');
    uno=char('on','off');
    ontotal=char('on','on');

 % Matriz de valores de la propiedad visible
   vinicial=char(viv,vv);


 % Valor de referencia para el fondo del boton
   
   valorp=1;
   
   
   if strcmp(ontotal,vinicial)==1
       
       return
   end
   
   
   if strcmp(offtotal,vinicial)==1
         
   set(handles.t1,'Userdata',valorp)
       
 % IMAGEN EN BOTON CAMARA 

        [a]=imread('CE6.jpg');
        [r,c]=size(a);
        x=ceil(r/100);
        y=ceil(c/500);
        g=a(1:x:end,1:y:end,:);
        g(g==255)=5.5*255;
        set(handles.t1,'CData',g);
       
set(handles.t1,'visible','on')
       
   
   elseif strcmp(vinicial,uno)==1
       
        % IMAGEN EN BOTON CAMARA 

        [a]=imread('CE6.jpg');
        [r,c]=size(a);
        x=ceil(r/100);
        y=ceil(c/500);
        g=a(1:x:end,1:y:end,:);
        g(g==255)=5.5*255;
        set(handles.t2,'CData',g);
       set(handles.t2,'visible','on')
       set(handles.t2,'Userdata',valorp)
   
   end
   


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)

% SELECCION CMARA DE EXPANSIN CON CONDUCTO EXTENDIDO

 % Se Obtiene la propiedad Visible de los Pushbutton donde va la combinacin de silenciadores  
    
    viv=get(handles.t1,'visible');
    vv=get(handles.t2,'visible');

 % Matrices para comparar con los valores obtenidos 
    
    offtotal=char('off','off');
    uno=char('on','off');
    ontotal=char('on','on');

 % Matriz de valores de la propiedad visible
   vinicial=char(viv,vv);


 % Valor de referencia para el fondo del boton
   
   valorp=2;
   
   
   if strcmp(ontotal,vinicial)==1
       
       return
   end
   
   
   if strcmp(offtotal,vinicial)==1
         
   set(handles.t1,'Userdata',valorp)
       
 % IMAGEN EN BOTON CAMARA 

        [a]=imread('CEXT6.jpg');
        [r,c]=size(a);
        x=ceil(r/100);
        y=ceil(c/500);
        g=a(1:x:end,1:y:end,:);
        g(g==255)=5.5*255;
        set(handles.t1,'CData',g);
       
set(handles.t1,'visible','on')
       
   
   elseif strcmp(vinicial,uno)==1
       
        % IMAGEN EN BOTON CAMARA 

        [a]=imread('CEXT6.jpg');
        [r,c]=size(a);
        x=ceil(r/100);
        y=ceil(c/500);
        g=a(1:x:end,1:y:end,:);
        g(g==255)=5.5*255;
        set(handles.t2,'CData',g);
       set(handles.t2,'visible','on')
       set(handles.t2,'Userdata',valorp)
   
   end
   
   
   
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)

% SELECCION CMARA CON RESONADOR CONCENTRICO

 % Se Obtiene la propiedad Visible de los Pushbutton donde va la combinacin de silenciadores  
    
    viv=get(handles.t1,'visible');
    vv=get(handles.t2,'visible');

 % Matrices para comparar con los valores obtenidos 
    
    offtotal=char('off','off');
    uno=char('on','off');
    ontotal=char('on','on');

 % Matriz de valores de la propiedad visible
   vinicial=char(viv,vv);


 % Valor de referencia para el fondo del boton
   
   valorp=3;
   
   
   if strcmp(ontotal,vinicial)==1
       
       return
   end
   
   
   if strcmp(offtotal,vinicial)==1
         
   set(handles.t1,'Userdata',valorp)
       
 % IMAGEN EN BOTON CAMARA 

        [a]=imread('RESC6.jpg');
        [r,c]=size(a);
        x=ceil(r/100);
        y=ceil(c/500);
        g=a(1:x:end,1:y:end,:);
        g(g==255)=5.5*255;
        set(handles.t1,'CData',g);
       
set(handles.t1,'visible','on')
       
   
   elseif strcmp(vinicial,uno)==1
       
        % IMAGEN EN BOTON CAMARA 

        [a]=imread('RESC6.jpg');
        [r,c]=size(a);
        x=ceil(r/100);
        y=ceil(c/500);
        g=a(1:x:end,1:y:end,:);
        g(g==255)=5.5*255;
        set(handles.t2,'CData',g);
       set(handles.t2,'visible','on')
       set(handles.t2,'Userdata',valorp)
   
   end





% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)

% ARCHIVO AYUDA

winopen('AYUDA.HLP')

%open('C:\Windows\winhlp32.exe')



% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
global TL TLterc BT fc;

f=0:4000; % Matriz de Frecuencias 
fnew=f(1,1:fc);
val=get(hObject,'value');

if val==1
    
axes(handles.axes1)
plot(fnew,TL(1:length(fnew)),'r')
xlabel('Frecuencia (Hz)','FontName','Lucida Console');
ylabel('TL (dB)','FontName','Lucida Console');
grid on;
set(handles.pushbutton11,'enable','off');

end

if val==2
    
%% CALCULO EN BANDAS DE TERCIO

q=(1:length(fnew));
TL=[TL(q) zeros(size(TL((length(q)+1):length(f))))];



set(handles.pushbutton11,'enable','off');
BT=[63;80;100;125;160;200;250;315;400;500;630;800;1000;1250;1600;2000;2500;3150;4000];

 a=size(BT);
 
Nmax=(a(1));
for mulf=1:Nmax
    fu=BT(mulf)/2^(1/6);
    fo=fu*2^(1/3);
    index=find((f<=fo)&(f>fu));
    a=size(index);
    Ndatos=a(2);
    TLterc(mulf)=10*log10(sum(10.^(TL(index)/10))/Ndatos);% Atenuacion en db y por bandas de tercios de Octava % Promedio Energetico

end

% Envio del resultado del TL dB a los static text correspondiente
    set(handles.text7,'string',round(TLterc(1))); %63 Hz
    set(handles.text8,'string',round(TLterc(2)));  % 80 Hz
    set(handles.text9,'string',round(TLterc(3)));  % 100 Hz
    set(handles.text10,'string',round(TLterc(4))); % 125 Hz
    set(handles.text11,'string',round(TLterc(5)));   %160 Hz
    set(handles.text12,'string',round(TLterc(6)));  % 200HZ
    set(handles.text13,'string',round(TLterc(7))); %250 Hz
    set(handles.text14,'string',round(TLterc(8)));    %315 Hz
    set(handles.text15,'string',round(TLterc(9)));  %400 Hz
    set(handles.text16,'string',round(TLterc(10)));   %500 Hz 
    set(handles.text17,'string',round(TLterc(11)));      % 630 Hz
    set(handles.text18,'string',round(TLterc(12))); %800 Hz
    set(handles.text19,'string',round(TLterc(13))); %1000 Hz
    set(handles.text20,'string',round(TLterc(14))); %1250 Hz
    set(handles.text21,'string',round(TLterc(15)));    % 1600 Hz
    set(handles.text22,'string',round(TLterc(16)));   %2000 Hz
    set(handles.text23,'string',round(TLterc(17)));     %2500 Hz
    set(handles.text24,'string',round(TLterc(18)));    %3150 Hz
    set(handles.text25,'string',round(TLterc(19)));   %4000 Hz
    

    axes(handles.axes1)

        bar(round(TLterc),'r');
        indicetick=[1 4 7 10 13 16 19];
        set(gca,'xtick',indicetick,'xticklabel',{'63';'125';'250';'500';'1000';'2000';'4000'});
        xlabel('Frecuencia (Hz)','FontName','Lucida Console');
        ylabel('TL (dB)','FontName','Lucida Console');
        grid on;
        
        set(handles.pushbutton2,'enable','on');
        
end






% --- 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


% --- Executes on button press in t1.
function t1_Callback(hObject, eventdata, handles)

% BOTON DE ENGANCHE  1


handles=guidata(gcbo);


global indicador


button_state = get(hObject,'Value');

if button_state == get(hObject,'Max')
    
    if exist('Matriz2.mat')
        set(handles.pushbutton11,'enable','on')
    end
    
handles.valorpt1=get(hObject,'Userdata');

if handles.valorpt1==1  % CAMARA DE EXPANSION SIMPLE
    
   
    indicador=1;
    
    CES;
    set(handles.t1,'Value',0)
end
    
if handles.valorpt1==2 % SILENCIADOR CON CONDUCTO EXTENDIDO EN LA ENTRADA
    
   indicador=1;
   
   CEXT;
   set(handles.t1,'Value',0)
end


if handles.valorpt1==3 % SILENCIADOR CON RESONADOR CONCENTRICO
    
    indicador=1;
    RES;
    set(handles.t1,'Value',0)
end


end

set(handles.t2,'Value',0)  
guidata(gcbo,handles)















% --- Executes on button press in t2.
function t2_Callback(hObject, eventdata, handles)

%BOTON ENGANCHE 2
handles=guidata(gcbo);

global indicador

button_state = get(hObject,'Value');

if button_state == get(hObject,'Max')
    
    if exist('Matriz1.mat')
        set(handles.pushbutton11,'enable','on')
    end

handles.valorpt1=get(hObject,'Userdata');


if handles.valorpt1==1  % CAMARA DE EXPANSION SIMPLE
    
    indicador=2;
    CES;
    set(handles.t2,'Value',0)  
   
end
    
if handles.valorpt1==2 % SILENCIADOR CON CONDUCTO EXTENDIDO EN LA ENTRADA
    
    indicador=2;
    CEXT;
    set(handles.t2,'Value',0)
end


if handles.valorpt1==3 % SILENCIADOR CON RESONADOR CONCENTRICO
    
    indicador=2;
    RES;
    set(handles.t2,'Value',0)
end

end

set(handles.t1,'Value',0)  
  
guidata(gcbo,handles)










function edit1_Callback(hObject, eventdata, handles)

% ENTRADA DE VALOR DE LA VARIABLE TEMPERATURA EN C

global t 

handles.t=str2double(get(hObject,'String'));

if isnan(handles.t)
errordlg('Debes ingresar un valor nmerico', 'Mala Entrada', 'modal')
set(hObject,'string',t);
return
end
if handles.t<=0
errordlg('Debes ingresar un valor positivo', 'Mala entrada', 'modal')
set(hObject,'string',t);
return
end

t=handles.t;







% --- 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)

global RHO 

handles.RHO=str2double(get(hObject,'String'));

if isnan(handles.RHO)
errordlg('Debes ingresar un valor nmerico', 'Mala Entrada', 'modal')
set(hObject,'string',RHO);
return
end
if handles.RHO<=0
errordlg('Debes ingresar un valor positivo', 'Mala entrada', 'modal')
set(hObject,'string',RHO);
return
end

RHO=handles.RHO;


% --- 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)

global Q

handles.Q=str2double(get(hObject,'String'));

if isnan(handles.Q)
errordlg('Debes ingresar un valor nmerico', 'Mala Entrada', 'modal')
set(hObject,'string',Q);
return
end
if handles.Q<0
errordlg('Debes ingresar un valor positivo', 'Mala entrada', 'modal')
set(hObject,'string',Q);
return
end

Q=handles.Q;


% --- 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


% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
 
% BOTON BORRAR

set(handles.pushbutton2,'enable','off');

% COLOCAR IMAGEN EN LOS EJES PRINCIPALES

r=zeros(1,4000);
f=1:4000;
axes(handles.axes1)
plot(f,r)
set(gca,'ylim',[0 100])
xlabel('Frecuencia (Hz)','FontName','Lucida Console','Fontweight','bold');
ylabel('TL (dB)','FontName','Lucida Console','Fontweight','bold');
grid on

% REINICIAR POPUP

set(handles.popupmenu1,'value',1);
set(handles.popupmenu1,'enable','off');


% limpiando TL dB a los static text correspondiente
    set(handles.text7,'string',''); %63 Hz
    set(handles.text8,'string','');  % 80 Hz
    set(handles.text9,'string','');  % 100 Hz
    set(handles.text10,'string',''); % 125 Hz
    set(handles.text11,'string','');   %160 Hz
    set(handles.text12,'string','');  % 200HZ
    set(handles.text13,'string',''); %250 Hz
    set(handles.text14,'string','');    %315 Hz
    set(handles.text15,'string','');  %400 Hz
    set(handles.text16,'string','');   %500 Hz 
    set(handles.text17,'string','');      % 630 Hz
    set(handles.text18,'string',''); %800 Hz
    set(handles.text19,'string',''); %1000 Hz
    set(handles.text20,'string',''); %1250 Hz
    set(handles.text21,'string','');    % 1600 Hz
    set(handles.text22,'string','');   %2000 Hz
    set(handles.text23,'string','');     %2500 Hz
    set(handles.text24,'string','');    %3150 Hz
    set(handles.text25,'string','');   %4000 Hz







    viv=get(handles.t1,'visible');
    vv=get(handles.t2,'visible');
   

    
    
    
 % Matrices para comparar con los valores obtenidos 
    
    offtotal=char('off','off');
    uno=char('on','off');
    ontotal=char('on','on');

 % Matriz de valores de la propiedad visible
   vinicial=char(viv,vv);
   
   if strcmp(offtotal,vinicial)==1
       
       return
   end
   
   

   if strcmp(ontotal,vinicial)==1
       
       set(handles.t2,'visible','off')
       set(handles.pushbutton11,'enable','off')
       if exist('t2.mat')
        delete('t2.mat')
       end

       if exist('Matriz2.mat')
        delete('Matriz2.mat')
       end
       
   elseif strcmp(vinicial,uno)==1
       
       
       set(handles.t1,'visible','off')
       
       if exist('t1.mat')
        delete('t1.mat')
       end
       
       if exist('Matriz1.mat')
        delete('Matriz1.mat')
       end
       
       
   end
   


% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)

% TL DE LA COMBINACIN DE MATRICES

set(handles.popupmenu1,'value',1)

% limpiando TL dB a los static text correspondiente
    set(handles.text7,'string',''); %63 Hz
    set(handles.text8,'string','');  % 80 Hz
    set(handles.text9,'string','');  % 100 Hz
    set(handles.text10,'string',''); % 125 Hz
    set(handles.text11,'string','');   %160 Hz
    set(handles.text12,'string','');  % 200HZ
    set(handles.text13,'string',''); %250 Hz
    set(handles.text14,'string','');    %315 Hz
    set(handles.text15,'string','');  %400 Hz
    set(handles.text16,'string','');   %500 Hz 
    set(handles.text17,'string','');      % 630 Hz
    set(handles.text18,'string',''); %800 Hz
    set(handles.text19,'string',''); %1000 Hz
    set(handles.text20,'string',''); %1250 Hz
    set(handles.text21,'string','');    % 1600 Hz
    set(handles.text22,'string','');   %2000 Hz
    set(handles.text23,'string','');     %2500 Hz
    set(handles.text24,'string','');    %3150 Hz
    set(handles.text25,'string','');   %4000 Hz



global t RHO TL fc;

load Matriz1
load Matriz2
load guardar1.mat
load guardar2.mat

if strcmp(nombre1,'CAMARA DE EXPANSIN SIMPLE')
    D1=S1D2;
    
    elseif strcmp(nombre1,'CAMARA CON CONDUCTO EXTENDIDO EN LA ENTRADA')
        D1=S1DC;
        
        elseif strcmp(nombre1,'CAMARA CON RESONADOR CONCENTRICO')
            D1=S1RDC;
end

            if strcmp(nombre2,'CAMARA DE EXPANSIN SIMPLE')
              D2=S2D2;
            elseif strcmp(nombre2,'CAMARA CON CONDUCTO EXTENDIDO EN LA ENTRADA')
                D2=S2DC;
                
                elseif strcmp(nombre2,'CAMARA CON RESONADOR CONCENTRICO')
                    D2=S2RDC;
            end

if D1>D2
    D=D1;
else 
    D=D2;
end


    
            
c=331*sqrt((t+273)/273);


f=0:4000; % Matriz de Frecuencias 

for aux=1:length(f);
    
    T=T1{aux}*T2{aux};
  

    
TL(aux)=20*log10(((S3/S1)^(1/2))*(1/2)*abs(T(1,1)+((S3/(RHO*c))*T(1,2))+(((RHO*c)/S1)*T(2,1))+(T(2,2)*(S1/S3))));
 
 end

axes(handles.axes1)
fc=find(f==round((1.84*c)/(pi*D)));
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;

set(handles.popupmenu1,'enable','on')




Contact us at files@mathworks.com