码迷,mamicode.com
首页 > 移动开发 > 详细

肌电信号的时域/频域分析-更新中

时间:2020-11-30 15:23:27      阅读:10      评论:0      收藏:0      [点我收藏+]

标签:create   end   until   rar   信号   windows   filename   密度   分析   

function varargout = tezheng(varargin)

gui_Singleton = 1;
gui_State = struct(‘gui_Name‘,       mfilename, ...
                   ‘gui_Singleton‘,  gui_Singleton, ...
                   ‘gui_OpeningFcn‘, @tezheng_OpeningFcn, ...
                   ‘gui_OutputFcn‘,  @tezheng_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 tezheng is made visible.
function tezheng_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 tezheng (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = tezheng_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)
%  s=get(handles.edit1,‘string‘);
a=load(get(handles.edit2,‘string‘));
x1=a(:,1);
axes(handles.axes1);
plot(x1)
xlabel(‘时间 (s)‘);
ylabel(‘被测变量y‘);
title(‘原始信号(时域)‘);
grid on;




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

% Hints: get(hObject,‘String‘) returns contents of edit1 as text
%        str2double(get(hObject,‘String‘)) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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 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)
a=load(get(handles.edit2,‘string‘));
x1=a(:,1);
axes(handles.axes2);
t1=GetRMS(x1, 300,50);
plot(t1)
xlabel(‘时间MS‘);
ylabel(‘RMS值uV‘);
title(‘时域RMS‘);
hold on;
grid on;
pj1=mean(t1);
ppjj=num2str(pj1);
set(handles.text11,‘string‘,ppjj);


% --- 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)
a=load(get(handles.edit2,‘string‘));
x1=a(:,1);
fs=1000;
N=512;%512
M=1; %调节因子
%数据点数
%时间序列
n=0:N-1;
f=n*fs/N;    %频率序列
y1=fft(x1,N);    %对信号进行快速Fourier变换
mag1=abs(y1);     %求得Fourier变换后的振幅
axes(handles.axes3);
plot(f(1:N/2),mag1(1:N/2));
xlabel(‘频率HZ‘);
ylabel(‘幅值uV‘);
title(‘频域MF‘);
L1=length(x1);
cx1=xcorr(x1,‘unbiased‘);
cxk1=fft(cx1,L1);
px1=abs(cxk1);%求功率谱密度
pxx1=10*log10(px1);
f1=(0:L1-1)*fs/L1;
df1=fs/L1;
p1=(sum(px1(1:L1/2-1))+sum(px1(1:L1/2)))/2.*df1;
pf1=(sum(px1(1:L1/2-1).*[1:L1/2-1]‘.*df1)+sum(px1(1:L1/2).*[1:L1/2]‘.*df1))/2*df1;
MPF1=pf1/p1 ;%求平均功率频率
N1=1;pp1=0;
while abs(pp1-p1/2)>(px1(N1)+px1(N1+1))/2*df1
    pp1=pp1+(px1(N1)+px1(N1+1))/2*df1;
    N1=N1+1;
end
n_1=(N1+N1+1)/2;
MF1=df1*n_1; %求中值频率
MF11=num2str(MF1)
set(handles.text14,‘string‘,MF11);



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

% Hints: get(hObject,‘String‘) returns contents of edit2 as text
%        str2double(get(hObject,‘String‘)) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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

  技术图片

 

 

肌电信号的时域/频域分析-更新中

标签:create   end   until   rar   信号   windows   filename   密度   分析   

原文地址:https://www.cnblogs.com/charles48789982/p/14032689.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!