⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.m

📁 Hearing test. It using music card to test left and right ear seperately. It contains graphic iterfac
💻 M
字号:


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

% Last Modified by GUIDE v2.5 15-Nov-2008 17:35:29

% Begin initialization code - DO NOT EDIT
global wynik;
disp('MAINNNNN')
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @main_OpeningFcn, ...
                   'gui_OutputFcn',  @main_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 main is made visible.
function main_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 main (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


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


% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
play(500,1,44100,1);
play(1000,1,44100,11);
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
function play(freq,time,samplingFreq,amplitude)
% utworz tablice
fs=samplingFreq;
f=freq;
t=0:1/fs:time;
y=amplitude*sin(2*pi*f*t);
wavplay(y,fs,'async');




% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1


% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns listbox2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox2


% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 listbox3.
function listbox3_Callback(hObject, eventdata, handles)
% hObject    handle to listbox3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns listbox3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox3


% --- Executes during object creation, after setting all properties.
function listbox3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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 pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles = guihandles;

lb3maxa=size(get(handles.listbox3,'String'));
lb3max=lb3maxa(1);
lb3pos=get(handles.listbox3,'Value');
if lb3pos<lb3max
    set(handles.listbox3,'Value',lb3pos+1);
else
    set(handles.listbox3,'Value',1);
    lb2maxa=size(get(handles.listbox2,'String'));
    lb2max=lb2maxa(1);
    lb2pos=get(handles.listbox2,'Value');
    if lb2pos<lb2max 
        set(handles.listbox2,'Value',lb2pos+1);
    end
  
end







% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
lb3Vals=get(handles.listbox3,'String');
lb3pos=get(handles.listbox3,'Value');
amp=lb3Vals(lb3pos);


lb2Vals=get(handles.listbox2,'String');
lb2pos=get(handles.listbox2,'Value');
freq1=lb2Vals(lb2pos);
freq1=str2double(freq1);
origamp=str2double(amp);
amp=power(10,origamp/20);
play(freq1,1,44100,amp/300);
title=sprintf('Cz:%d P:%d dB',freq1,amp);
button =  questdlg('Dzwiek s硑szalny?',title,'TAK','NIE','NIE'); 
if button=='TAK' 
   dzwUslyszany(freq1,origamp);
else 
     handles = guihandles;

    lb3maxa=size(get(handles.listbox3,'String'));
    lb3max=lb3maxa(1);
    lb3pos=get(handles.listbox3,'Value');
    if lb3pos<lb3max
        set(handles.listbox3,'Value',lb3pos+1);
    else
     set(handles.listbox3,'Value',1);
     lb2maxa=size(get(handles.listbox2,'String'));
     lb2max=lb2maxa(1);
      lb2pos=get(handles.listbox2,'Value');
      if lb2pos<lb2max 
        set(handles.listbox2,'Value',lb2pos+1);
      end
      
  
    end
end


% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2

function dzwUslyszany(freqq,ampp)
global wynik
handles = guihandles;
lb4Vals=get(handles.listbox4,'String');
lb4pos=get(handles.listbox4,'Value');
ucho=cell2mat(lb4Vals(lb4pos));
switch lower(ucho)
     case {'ucho lewe'}
      ucho=1;
   otherwise
      ucho=2;
end 
disp(sprintf('Dzwiek uslyszany Ucho %d freq %d amp %d',ucho,freqq,ampp));
wynik(ucho,freqq)=ampp;
handles = guihandles;
    set(handles.listbox3,'Value',1);
    lb2maxa=size(get(handles.listbox2,'String'));
    lb2max=lb2maxa(1);
    lb2pos=get(handles.listbox2,'Value');
    if lb2pos<lb2max 
        set(handles.listbox2,'Value',lb2pos+1);
    else
     lb4pos=get(handles.listbox4,'Value');
      
       if lb4pos==1 
          set(handles.listbox2,'Value',1); 
          set(handles.listbox3,'Value',1); 
          set(handles.listbox4,'Value',2);
          msgbox('Prosz

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -