基于matlab的肌电信号处理程序:

基于matlab的肌电信号处理程序:
基于matlab的肌电信号处理程序:

基于matlab的肌电信号处理程序:

function varargout = untitled(varargin)

% UNTITLED M-file for untitled.fig

% UNTITLED, by itself, creates a new UNTITLED or raises the existing

% singleton*.

%

% H = UNTITLED returns the handle to a new UNTITLED or the handle to

% the existing singleton*.

%

% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in UNTITLED.M with the given input arguments. %

% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before untitled_OpeningFcn gets called. An

% unrecognized property name or invalid value makes property application % stop. All inputs are passed to untitled_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 untitled

% Last Modified by GUIDE v2.5 08-Nov-2014 12:45:18

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', untitled_OpeningFcn, ...

'gui_OutputFcn', untitled_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 untitled is made visible.

function untitled_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 untitled (see VARARGIN)

% Choose default command line output for untitled

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = untitled_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)

global s;

global a;

global t;

global count;

% count=1;

[filename,filepath]=uigetfile('*.txt','???????t');%????êy?Y???t

str=[filepath filename];

s=load(str);

a=s(:,7);

t=s(:,1);

axes(handles.axes1);

plot(t,a);

xlabel('ê±??');

ylabel('±?á?');

title('?-ê?D?o?');

if count==2

global s2;

global a2;

global t2;

[filename,filepath]=uigetfile('*.txt','???????t');

str=[filepath filename];

s2=load(str);

a2=s2(:,7);

t2=s2(:,1);

plot(handles.axes2,t2,a2);

end

count=1;

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles)

% 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) global a;

global t;

global s;

global y;

% global IR;

% global SORH;

y=fft(a,20000);

M =length (a) ;

N=length(y);

p=size(a);

% s1=a(1:20000);

[C L]=wavedec(a,3,'db5');

cA3=appcoef(C,L,'db5',3);

cD1=detcoef(C,L,1);

cD2=detcoef(C,L,2);

cD3=detcoef(C,L,3);

thr1=thselect(cD1,'rigrsure');

thr2=thselect(cD2,'rigrsure');

thr3=thselect(cD3,'rigrsure');

TR=[thr1,thr2,thr3];

SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,...

'db5',3,TR,SORH);

L=p(2);

x=a;

h=XC;

F=0;

M=0;

for ii=1:L

m(ii)=(x(ii)-y(ii))^2;

t(ii)=y(ii)^2;

f(ii)=t(ii)/m(ii);

F=F+f(ii);

M=M+m(ii);

end;

SNR=10*log10(F);

MSE=M/N;

SM=SNR/MSE;

axes(handles.axes2);

plot(XC(1:10000));

xlabel('ê±??');

ylabel('±?á?');

title('è¥??oóD?o?');

% plot(handles.axes2,XC(1:20000));

% --- 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) global a;

global t;

global y;

global count;

%a=EMG3(1:points,2);

y=fft(a,20000); %??D?o???DD?ì?ùFourier±???

fs=2000;

N=length(y);

mag=abs(y);%?óμ?Fourier±???oóμ???·ù

f=(0:N-1)/N*fs; %?μ?êDòáD

axes(handles.axes1);

plot(f,mag);

% plot(handles.axes1,f,mag);%????í?D?

xlabel('?μ?ê');

ylabel('·ù?μ');

title('?-??μ?·ù?μN=20000');

if count==2

global a2;

global t2;

global y2;

%a=EMG3(1:points,2);

y2=fft(a2,20000); %??D?o???DD?ì?ùFourier±???

fs=2000;

N=length(y2);

mag=abs(y2);%?óμ?Fourier±???oóμ???·ù

f=(0:N-1)/N*fs; %?μ?êDòáD

axes(handles.axes2);

plot(f,mag);

end

count=1;

% --- 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) global a;

global t;

% global IR;

% global SORH;

[C L]=wavedec(a,3,'db5');

cA3=appcoef(C,L,'db5',3);

cD1=detcoef(C,L,1);

cD2=detcoef(C,L,2);

cD3=detcoef(C,L,3);

thr1=thselect(cD1,'rigrsure');

thr2=thselect(cD2,'rigrsure');

thr3=thselect(cD3,'rigrsure');

TR=[thr1,thr2,thr3];

SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,...

'db5',3,TR,SORH);

y1=fft(XC,20000);

fs=2000;

N=length(y1);

mag1=abs(y1);

f=(0:N-1)/N*fs;

axes(handles.axes2);

plot(f,mag1);

xlabel('?μ?ê');

ylabel('·ù?μ');

title('è¥??oó·ù?μN=20000');

% --- Executes on button press in pushbutton5.

function pushbutton5_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton5 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a;

global t;

global y;

global count;

fs=2000;

N=length(y);

f=(0:N-1)/N*fs;%?μ?êDòáD

axes(handles.axes1);

plot(f,angle(y));

xlabel('?μ?ê');

ylabel('?à??');

title('?-??μ??à?μ');

% plot(handles.axes1,f,angle(y));%?????à?μì?D?í?

if count==2

global a2;

global t2;

global y2;

fs=2000;

N=length(y2);

f=(0:N-1)/N*fs;%?μ?êDòáD

axes(handles.axes2);

plot(f,angle(y2));

xlabel('?μ?ê');

ylabel('?à??');

title('?-??μ??à?μ');

end

count=1;

% plot(handles.axes1,f,angle(y));%?????à?μì?D?í?

% --- Executes on button press in pushbutton6.

function pushbutton6_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton6 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a;

global t;

[C L]=wavedec(a,3,'db5');

cA3=appcoef(C,L,'db5',3);

cD1=detcoef(C,L,1);

cD2=detcoef(C,L,2);

cD3=detcoef(C,L,3);

thr1=thselect(cD1,'rigrsure');

thr2=thselect(cD2,'rigrsure');

thr3=thselect(cD3,'rigrsure');

TR=[thr1,thr2,thr3];

SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,...

'db5',3,TR,SORH);

y1=fft(XC,20000);

fs=2000;

N=length(y1);

f=(0:N-1)/N*fs;

axes(handles.axes2);

plot(f,angle(y1));

xlabel('?μ?ê');

ylabel('?à??');

title('è¥??oó??μ??à?μ');

% --- Executes on button press in pushbutton7.

function pushbutton7_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton7 (see GCBO)

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

try

delete(allchild(handles.axes1));

delete(allchild(handles.axes2));

相关主题
相关文档
最新文档