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

📄 voicelevelgui.m

📁 matlab数据采集工具箱应用示例。gui是在matlab7.0.1下设计
💻 M
📖 第 1 页 / 共 3 页
字号:
function varargout = voiceLevelGUI(varargin)
% VOICELEVELGUI M-file for voiceLevelGUI.fig
%      VOICELEVELGUI, by itself, creates a new VOICELEVELGUI or raises the existing
%      singleton*.
%
%      H = VOICELEVELGUI returns the handle to a new VOICELEVELGUI or the handle to
%      the existing singleton*.
%
%      VOICELEVELGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in VOICELEVELGUI.M with the given input arguments.
%
%      VOICELEVELGUI('Property','Value',...) creates a new VOICELEVELGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before voiceLevelGUI_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to voiceLevelGUI_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help voiceLevelGUI

% Last Modified by GUIDE v2.5 29-May-2005 21:31:22

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

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

% Update handles structure
guidata(hObject, handles);

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

% 坐标轴初始化
axes(handles.axes1);
xlabel('Sample');
ylabel('Analog Input (Volts)');
title('Analog Data Acquisition');

axes(handles.axes2);
hxlabel = xlabel('Frequency (Hz)');
hylabel = ylabel('Magnitude (dB)');

axes(handles.axesL1);
ylabel('Magnitude(dB)');

axes(handles.axesLL1);
ylabel('Magnitude(dB)');

%% 初始化appdata
setappdata(handles.voiceLevelGUI,'BandData',[]);
setappdata(handles.voiceLevelGUI,'Band2Data',[]);

% 日期时间显示
set(handles.timestr,'string',datestr(now,0));
htimer = timer('StartDelay',1,'TimerFcn',...
    'htimestr=findall(0,''tag'',''timestr'');set(htimestr,''string'',datestr(now,0));',...
    'Period',1,'ExecutionMode','fixedSpacing','tag','showtime');
start(htimer);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 可以在这里写入一些初始化操作
% 我这里以前写的是身份验证的一个小的加密的程序段
% sn
filename=matlabroot;
filename=[filename,'\voiceLevelGUIsn.bin'];
if(exist(filename)==0)
    fid=fopen(filename,'w+');
    fileattrib(filename,'+h');
    sn=[0,1];
    fwrite(fid,sn,'integer*4');
    fclose(fid);
else
    fid=fopen(filename,'r');
    sn=fread(fid,2,'int32');
    fclose(fid);
    if(sn(1)==0)
        num=sn(2)+1;
        sn(2)=num;
        if(num>5)
            answer=inputdlg('请输入注册号:','Please enter your SN');
            if(~isempty(answer))
                str=answer{1};
                snn=str2num(str);
                if snn==987656789
                    sn(1)=1;
                    fileattrib(filename,'-h');
                    fid=fopen(filename,'w');
                    fwrite(fid,sn,'integer*4');
                    fclose(fid);
                    fileattrib(filename,'+h');
                else
                    uiwait(msgbox('输入的注册号不正确!','注册号出错','error','modal'));
                    set(handles.btnRun,'Enable','off');
                end
            else
                uiwait(msgbox('输入的注册号不正确!','注册号出错','error','modal'));
                set(handles.btnRun,'Enable','off');
            end
        else
            fileattrib(filename,'-h');
            fid=fopen(filename,'w');
            fwrite(fid,sn,'integer*4');
            fclose(fid);
            fileattrib(filename,'+h');
        end
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% --- Outputs from this function are returned to the command line.
function varargout = voiceLevelGUI_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 mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function voiceLevelGUI_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to voiceLevelGUI (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% get(gcf,'position');


% --- Executes during object creation, after setting all properties.
function editSamplesPerT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editSamplesPerT (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 during object creation, after setting all properties.
function editSampleR_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editSampleR (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 during object creation, after setting all properties.
function editTimerPeriod_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editTimerPeriod (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 during object creation, after setting all properties.
function editChan_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editChan (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 during object creation, after setting all properties.
function editId_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editId (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 during object creation, after setting all properties.
function editL1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editL1 (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 during object creation, after setting all properties.
function editL2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editL2 (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 during object creation, after setting all properties.
function editL3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editL3 (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 during object creation, after setting all properties.
function editL4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editL4 (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 during object creation, after setting all properties.
function editL5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editL5 (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 during object creation, after setting all properties.
function editLL1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editLL1 (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 during object creation, after setting all properties.
function editLL2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editLL2 (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 during object creation, after setting all properties.
function editLL3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editLL3 (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 during object creation, after setting all properties.
function editLL4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editLL4 (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.

⌨️ 快捷键说明

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