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

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

% Last Modified by GUIDE v2.5 25-Oct-2009 19:47:11

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

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


load SP

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

[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.guardar,'CData',g);


% GRAFICO

axes(handles.axes1)
plot(f,TL,'-r','LineWidth',4)
xlabel('Frecuencia (Hz)','Fontsize',14);
ylabel('Atenuacin TL','Fontsize',14);
set(gca,'Fontsize',14);
grid on;


% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = Grafico_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 selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)

global TLterc TLtercA BT

load SP

val = get(hObject,'Value');

switch val
    
    case 1 
        axes(handles.axes1)
        plot(f,TL,'-r','LineWidth',4)
        xlabel('Frecuencia (Hz)','Fontsize',14);
        ylabel('Atenuacin TL','Fontsize',14);
        set(gca,'Fontsize',14);
        grid on;
        
         
      case 2 
        
        axes(handles.axes1)
        semilogx(f,TL,'-r','LineWidth',4)
        xlabel('Frecuencia (Hz)','Fontsize',14);
        ylabel('Atenuacin TL','Fontsize',14);
        set(gca,'Fontsize',14);
        grid on;
          
          
      case 3
        
        axes(handles.axes1)
        loglog(f,TL,'-r','LineWidth',4)
        xlabel('Frecuencia (Hz)','Fontsize',14);
        ylabel('Atenuacin TL','Fontsize',14);
        set(gca,'Fontsize',14);
        grid on;
        
        case 4
          
%% Calculo en Bandas de Tercio de Octava

BT=[63;80;100;125;160;200;250;315;400;500;630;800;1000;1250;1600;2000;2500;3150;4000;5000;6300;8000];
a=size(BT);
Nmax=(a(1));
for aux=1:Nmax
    fu=BT(aux)/2^(1/6);
    fo=fu*2^(1/3);
    index=find((f<=fo)&(f>fu));
    a=size(index);
    Ndatos=a(2);
    TLterc(aux)=10*log10(sum(10.^(TL(index)/10))/Ndatos);% Atenuacion en db y por bandas de tercios de Octava 
    
end;

axes(handles.axes1)
indicetick=[1 4 7 10 13  16 19 22];
plot(TLterc,'-r','LineWidth',4)
set(gca,'Xtick',indicetick)
set(gca,'Xticklabel',{'63';'125';'250';'500';'1000';'2000';'4000';'8000'});
xlabel('Frecuencia (Hz)','Fontsize',14);
ylabel('Atenuacin TL','Fontsize',14);
grid on;    

    case 5
        
        %% Calculo en Bandas de Tercio de Octava

BT=[63;80;100;125;160;200;250;315;400;500;630;800;1000;1250;1600;2000;2500;3150;4000;5000;6300;8000];
dba=[26.2;22.5;19.1;16.1;13.4;10.9;8.9;6.6;4.8;3.2;1.9;0.8;0;-0.6;-1;-1.2;-1.3;-1.2;-1;-0.5;0.1;1.1];
a=size(BT);
Nmax=(a(1));
for aux=1:Nmax
    fu=BT(aux)/2^(1/6);
    fo=fu*2^(1/3);
    index=find((f<=fo)&(f>fu));
    a=size(index);
    Ndatos=a(2);
    TLterc(aux)=10*log10(sum(10.^(TL(index)/10))/Ndatos);% Atenuacion en db y por bandas de tercios de Octava 
    
end

TLtercA=TLterc-dba';
axes(handles.axes1)
indicetick=[1 4 7 10 13  16 19 22];
plot(TLtercA,'-r','LineWidth',4)
set(gca,'Xtick',indicetick)
set(gca,'Xticklabel',{'63';'125';'250';'500';'1000';'2000';'4000';'8000'});
xlabel('Frecuencia (Hz)','Fontsize',14);
ylabel('Atenuacin TL','Fontsize',14);
grid 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 guardar.
function guardar_Callback(hObject, eventdata, handles)

global N hh dd H Q L t rho Po Fe Rf v TLterc TLtercA deltap BT ES

load SP


[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') ;


fprintf(fi,'%s\n\n\n',char('SILENCIADOR TIPO SPLITTER: '));

fprintf(fi,'%s\n\n\n',char('DUCTO: '));

fprintf(fi,'Altura H: %6.2f m\n',H);
fprintf(fi,'Nmero de Canales de Paso de Aire : %6.2f \n\n\n',N);

fprintf(fi,'%s\n\n\n',char('Baffle: '));

fprintf(fi,'Ancho Canal Paso de Aire 2h: %6.2f m\n',hh);
fprintf(fi,'Ancho Baffle 2d: %6.2f m\n',dd);
fprintf(fi,'Longitud del Baffle L: %6.2f m\n\n\n',L);

fprintf(fi,'%s\n\n\n',char('Condiciones del Medio: '));
fprintf(fi,'Flujo Volumetrico Q: %6.2f m3/hr\n',Q);
fprintf(fi,'Temperatura T: %6.2f C\n',t);
fprintf(fi,'Densidad : %6.2f Kg/m3\n',rho);
fprintf(fi,'Velocidad de flujo: %6.2f m/s\n\n\n',v);

fprintf(fi,'%s\n\n\n',char('Prametros del Material Absorbente: '));

fprintf(fi,'Porosidad: %6.2f \n',Po);
fprintf(fi,'Factor de Estructura : %6.2f \n',Fe);
fprintf(fi,'Resistencia al flujo por unidad de espesor: %6.2f Rayls/m\n\n\n',Rf);

fprintf(fi,'%s\n\n\n',char('Cada de Presin: '));

switch ES
    
    case 1
        
        fprintf(fi,'%s\n\n\n',char('Forma de Entrada Baffle: Rectangular '));
        fprintf(fi,'%s\n\n\n',char('Forma de Salida Baffle: Rectangular '));
        
    case 2

        fprintf(fi,'%s\n\n\n',char('Forma de Entrada Baffle: Circular '));
        fprintf(fi,'%s\n\n\n',char('Forma de Salida Baffle: Circular'));
        
    case 3
        
        fprintf(fi,'%s\n\n\n',char('Forma de Entrada Baffle: Rectangular '));
        fprintf(fi,'%s\n\n\n',char('Forma de Salida Baffle: Circular'));
        
    case 4
        
        fprintf(fi,'%s\n\n\n',char('Forma de Entrada Baffle: Circular '));
        fprintf(fi,'%s\n\n\n',char('Forma de Salida Baffle: Rectangular'));
        
end
        
        

fprintf(fi,'Prdida de Presin Total: %6.2f Pa\n\n\n',deltap);



    
    

fprintf(fi,'%s\n\n\n',char('Prdida de Transmisin TL: '));


 

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

switch val
    
    case 1
        
        fprintf(fi,'%s\n\n\n',char('TL dB: '));
        
        PTL=[f;TL];
        
        fprintf(fi,'%6.f %6.f\n',PTL);
        
        
    case 2
        
        fprintf(fi,'%s\n\n\n',char('TL dB: '));
        
        PTL=[f;TL];
        
        fprintf(fi,'%6.f %6.f\n',PTL);
        
        
    case 3
        
        
        fprintf(fi,'%s\n\n\n',char('TL dB: '));
        
        PTL=[f;TL];
        
        fprintf(fi,'%6.f %6.f\n',PTL);
        
    case 4
        
        
    fprintf(fi,'%s\n\n\n',char('TL 1/3 de Octava dB: '));

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

    fprintf(fi,'%6.f %6.f\n',PT);
    
    case 5
        
        fprintf(fi,'%s\n\n\n',char('TL 1/3 de Octava dBA: '));

        PTA=[BT';round(TLtercA)];

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

fclose(fi);


end





Contact us at files@mathworks.com