Скачиваний:
43
Добавлен:
25.12.2019
Размер:
8.63 Кб
Скачать
function varargout = GUI_program(varargin)
% GUI_PROGRAM MATLAB code for GUI_program.fig
% GUI_PROGRAM, by itself, creates a new GUI_PROGRAM or raises the existing
% singleton*.
%
% H = GUI_PROGRAM returns the handle to a new GUI_PROGRAM or the handle to
% the existing singleton*.
%
% GUI_PROGRAM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_PROGRAM.M with the given input arguments.
%
% GUI_PROGRAM('Property','Value',...) creates a new GUI_PROGRAM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_program_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_program_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 GUI_program

% Last Modified by GUIDE v2.5 16-Nov-2019 21:54:09

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = GUI_program_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;
%% Исходный сигнал
S=load('Signal_02_2.txt'); % Чтение сигналов из файла
Fs=250;
N=length(S);% Число отсчетов в каждом сигнале
x=S(1:N,1); % Массив (вектор) отсчетов ЭКГ
T=1/Fs; % Интервал дискретизации для исxодной частоты
tmax=N*T; % Размер фрагмента сигнала
t=0:T:tmax-T; % Время изменения сигнала
axes(handles.axes1);
plot(t,x);
ylim([-1.1, 1.5])
grid minor;
%% Фильтрация с помощью цифрового фильтра
M1=6;
S_f=zeros(1,N);
for n=M1:N
S_f(n)=0.968979151360102708423482908983714878559*S(n)-0.598862049930572459821576103422557935119*S(n-1)+0.968979151360102708423482908983714878559*S(n-2)-S_f(n)+0.598862049930572459821576103422557935119*S_f(n-1)-0.937958302720205416846965817967429757118*S_f(n-2);
end
axes(handles.axes2);
plot(t,S_f) ;
ylim([-1.1, 1.5])
grid minor
axes(handles.axes3);
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (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 radiobutton1


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

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


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

% Hint: popupmenu 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 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)
nfft=2048;
S=load('Signal_02_2.txt');
N=length(S);
M1=6;
S_f=zeros(1,N);
for n=M1:N
S_f(n)=0.968979151360102708423482908983714878559*S(n)-0.598862049930572459821576103422557935119*S(n-1)+0.968979151360102708423482908983714878559*S(n-2)-S_f(n)+0.598862049930572459821576103422557935119*S_f(n-1)-0.937958302720205416846965817967429757118*S_f(n-2);
end
tip_signala1=get(handles.radiobutton3,'Value');
tip_signala2=get(handles.radiobutton4,'Value');
tip_okna=get(handles.popupmenu1,'Value');
if tip_signala1==1
if tip_okna==1
SPM=periodogram(S,rectwin(N),nfft)
end
if tip_okna==2
SPM=periodogram(S,tukeywin(N),nfft)
end
if tip_okna==3
SPM=periodogram(S,hann(N),nfft)
end
tip_mashtaba1=get(handles.radiobutton1,'Value');
tip_mashtaba2=get(handles.radiobutton2,'Value');
axes(handles.axes3);
if tip_mashtaba1==1
plot(SPM)
end
if tip_mashtaba2==1
semilogy(SPM)
end
grid minor
xlim([0, length(SPM)])
ylim([min(SPM)-0.15, max(SPM)+0.15])
end
if tip_signala2==1
if tip_okna==1
SPM=periodogram(S_f,rectwin(N),nfft)
end
if tip_okna==2
SPM=periodogram(S_f,tukeywin(N),nfft)
end
if tip_okna==3
SPM=periodogram(S_f,hann(N),nfft)
end
tip_mashtaba1=get(handles.radiobutton1,'Value');
tip_mashtaba2=get(handles.radiobutton2,'Value');
axes(handles.axes3);
if tip_mashtaba1==1
plot(SPM)
end
if tip_mashtaba2==1
semilogy(SPM)
end
grid minor
xlim([0, length(SPM)])
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


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


% --- 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)
S=load('Signal_02_2.txt');
N=length(S);
M1=6;
S_f=zeros(1,N);
for n=M1:N
S_f(n)=0.968979151360102708423482908983714878559*S(n)-0.598862049930572459821576103422557935119*S(n-1)+0.968979151360102708423482908983714878559*S(n-2)-S_f(n)+0.598862049930572459821576103422557935119*S_f(n-1)-0.937958302720205416846965817967429757118*S_f(n-2);
end
tip_signala1=get(handles.radiobutton3,'Value');
tip_signala2=get(handles.radiobutton4,'Value');
if tip_signala1==1
correlation=xcorr(S,'coeff',round(N/2));
axes(handles.axes5);
plot(correlation)
xlim([0, length(correlation)])
grid minor
end
if tip_signala2==1
correlation=xcorr(S_f,'coeff',round(N/2));
axes(handles.axes5);
plot(correlation)
xlim([0, length(correlation)])
grid minor
end
Соседние файлы в папке Альтернативный вариант