肌电信号的时域和频域分析 联系客服

发布时间 : 星期六 文章肌电信号的时域和频域分析更新完毕开始阅读33c7743902020740bf1e9b18

% Update handles structure guidata(hObject, handles);

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

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

[filename,filepath]=uigetfile('*.txt','选择文件');%选择数据文件 str=[filepath filename]; s=load(str); a=s(:,7); t=s(:,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) try

delete(allchild(handles.axes1)); end

21

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

plot(handles.axes1,t,a);title('信号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 y;

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

y=fft(a,20000); %对信号进行快速Fourier变换 fs=2000;

N=length(y);

mag=abs(y);%求得Fourier变换后的振幅 f=(0:N-1)/N*fs; %频率序列

plot(handles.axes1,f,mag);%绘制图形

% --- 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; fs=2000;

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

plot(handles.axes1,f,angle(y));

% --- Executes on button press in pushbutton6.

function pushbutton6_Callback(hObject, eventdata, handles)

22

% 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; global s; global y; % global IR; % global SORH; M =length (a) ; N=length(y); p=size(a); s=a(1:20000);

[C L]=wavedec(a,4,'db5'); cA3=appcoef(C,L,'db5',4); cD1=detcoef(C,L,1); cD2=detcoef(C,L,2); cD3=detcoef(C,L,3); cD4=detcoef(C,L,4);

thr1=thselect(cD1,'rigrsure'); thr2=thselect(cD2,'rigrsure'); thr3=thselect(cD3,'rigrsure'); thr4=thselect(cD4,'rigrsure'); TR=[thr1,thr2,thr3,thr4]; SORH='s';

[XC,CXC,LXC,PERFO,PERF2]=wdencmp('lvd',a,... 'db5',4,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; % K=length(d);

23

% t1=(0:K-1)/2000;

plot(handles.axes5,XC(1:20000));

% --- 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) %去噪后幅频 global a; global t; %global h;

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

plot(handles.axes5,f,mag1);

% --- Executes on button press in pushbutton8.

function pushbutton8_Callback(hObject, eventdata, handles) % hObject handle to pushbutton8 (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);

24