function varargout = mygui(varargin)
%MYGUI M-file for mygui.fig
% MYGUI, by itself, creates a new MYGUI or raises the existing
% singleton*.
%
% H = MYGUI returns the handle to a new MYGUI or the handle to
% the existing singleton*.
%
% MYGUI('Property','Value',...) creates a new MYGUI using the
% given property value pairs. Unrecognized properties are passed via
% varargin to mygui_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% MYGUI('CALLBACK') and MYGUI('CALLBACK',hObject,...) call the
% local function named CALLBACK in MYGUI.M with the given input
% arguments.
%
% *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 mygui
% Last Modified by GUIDE v2.5 22-Aug-2020 01:21:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', 'E:\Education\7th Semester\FYP\DATA\Alarm Clock\graphmpu1.fig', ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mygui_OpeningFcn, ...
'gui_OutputFcn', @mygui_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 mygui is made visible.
function mygui_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 unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for mygui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes mygui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mygui_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;
function edit16_Callback(hObject, eventdata, handles)
% hObject handle to edit16 (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 edit16 as text
% str2double(get(hObject,'String')) returns contents of edit16 as a double
% --- Executes during object creation, after setting all properties.
function edit16_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit16 (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
function edit17_Callback(hObject, eventdata, handles)
% hObject handle to edit17 (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 edit17 as text
% str2double(get(hObject,'String')) returns contents of edit17 as a double
% --- Executes during object creation, after setting all properties.
function edit17_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit17 (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 data_pushbutton.
function data_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to data_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uigetfile({'*.xlsx'},'File Selector');
data_file_name=strcat(pathname,filename);
data=xlsread(data_file_name);
axes(handles.axes1);
sampledata=1:200;
plot(sampledata,data(1:200,3),'r-',sampledata,data(1:200,4),'g-',sampledata,data(1:200,5),'b-')
legend('Accelerometer1 x-axis', 'Accelerometer1 y-axis', 'Accelerometer1 z-axis')
xlabel('No. of Samples')
ylabel('Acceleration Values')
accdata1=data(1:200,3:5);
save accdata1 accdata1
%loading gyr1 data
axes(handles.axes2);
plot(sampledata,data(1:200,6),'r-',sampledata,data(1:200,7),'g-',sampledata,data(1:200,8),'b-')
legend('Gyroscope1 x-axis', 'Gyroscope1 y-axis', 'Gyroscope1 z-axis')
xlabel('No. of Samples')
ylabel('Acceleration Values')
gyrdata1=data(1:200,6:8);
save gyrdata1 gyrdata1
axes(handles.axes3);
sampledata=1:200;
plot(sampledata,data(1:200,9),'r-',sampledata,data(1:200,10),'g-',sampledata,data(1:200,11),'b-')
legend('Accelerometer2 x-axis', 'Accelerometer2 y-axis', 'Accelerometer2 z-axis')
xlabel('No. of Samples')
ylabel('Acceleration Values')
accdata2=data(1:200,9:11);
save accdata2 accdata2
%loading gyr1 data
axes(handles.axes4);
plot(sampledata,data(1:200,12),'r-',sampledata,data(1:200,13),'g-',sampledata,data(1:200,14),'b-')
legend('Gyroscope2 x-axis', 'Gyroscope2 y-axis', 'Gyroscope2 z-axis')
xlabel('No. of Samples')
ylabel('Acceleration Values')
axes(handles.axes9);
plot(sampledata,data(1:200,15),'r-',sampledata,data(1:200,16),'g-',sampledata,data(1:200,17),'b-',sampledata,data(1:200,18),'y-')
legend('Flex1', 'Flex2', 'Flex3','Flex4')
xlabel('No. of Samples')
ylabel('Acceleration Values')
gyrdata2=data(1:200,12:14);
save gyrdata2 gyrdata2
data2=data(1:200,:);
save data2 data2
% --- Executes on button press in features_pushbutton12.
function features_pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to features_pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load data2
load accdata1
load accdata2
load gyrdata1
load gyrdata2
accx1=data2(1:50,3);
accy1=data2(1:50,4);
accz1=data2(1:50,5);
gyx1=data2(1:50,6);
gyy1=data2(1:50,7);
gyz1=data2(1:50,8);
accx2=data2(1:50,9);
accy2=data2(1:50,10);
accz2=data2(1:50,11);
gyx2=data2(1:50,12);
gyy2=data2(1:50,13);
gyz2=data2(1:50,14);
flex1=data2(1:50,15);
flex2=data2(1:50,16);
flex3=data2(1:50,17);
flex4=data2(1:50,18);
gyro1_x_rms=rms(gyx1);
gyro1_y_rms=rms(gyx1);
gyro1_z_rms=rms(gyx1);
gyro2_x_rms=rms(gyx1);
gyro2_y_rms=rms(gyx1);
gyro2_z_rms=rms(gyx1);
acc1_x_mean=mean(accx1);
acc1_y_mean=mean(accy1);
acc1_z_mean=mean(accz1);
acc2_x_mean=mean(accx2);
acc2_y_mean=mean(accy2);
acc2_z_mean=mean(accz2);
acc1_x_std=std(accx1);
acc1_y_std=std(accy1);
acc1_z_std=std(accz1);
acc2_x_std=std(accx2);
acc2_y_std=std(accy2);
acc2_z_std=std(accz2);
corr1_xy= sum(accx1.*accy1)/(sqrt(sum(accx1.*accx1)*sum(accy1.*accy1)));
corr1_xz= sum(accx1.*accz1)/(sqrt(sum(accx1.*accx1)*sum(accz1.*accz1)));
corr1_yz= sum(accz1.*accy1)/(sqrt(sum(accz1.*accz1)*sum(accy1.*accy1)));
corr2_xy= sum(accx2.*accy2)/(sqrt(sum(accx2.*accx2)*sum(accy2.*accy2)));
corr2_xz= sum(accx2.*accz2)/(sqrt(sum(accx2.*accx2)*sum(accz2.*accz2)));
corr2_yz= sum(accz2.*accy2)/(sqrt(sum(accz2.*accz2)*sum(accy2.*accy2)));
entropy1_x=entropy(accx1);
entropy1_y=entropy(accy1);
entropy1_z=entropy(accz1);
entropy2_x=entropy(accx2);
entropy2_y=entropy(accy2);
entropy2_z=entropy(accz2);
fft_mag1_x=fft(accx1);
fft_mag1_y=fft(accy1);
fft_mag1_z=fft(accz1);
fft_mag1=abs(fftshift(fft_mag1_x))+abs(fftshift(fft_mag1_y))+abs(fftshift(fft_mag1_z));
freq_peak1=max(fft_mag1);
low1_f1=sum(fft_mag1(25:29));
low1_f2=sum(fft_mag1(30:34));
low1_f3=sum(fft_mag1(35:39));
mid_freq1=sum(fft_mag1(40:44));
high_freq1=sum(fft_mag1(45:50));
fft_mag2_x=fft(accx2);
fft_mag2_y=fft(accy2);
fft_mag2_z=fft(accz2);
fft_mag2=abs(fftshift(fft_mag2_x))+abs(fftshift(fft_mag2_y))+abs(fftshift(fft_mag2_z));
freq_peak2=max(fft_mag2);
low2_f1=sum(fft_mag2(25:29));
low2_f2=sum(fft_mag2(30:34));
low2_f3=sum(fft_mag2(35:39));
mid_freq2=sum(fft_mag2(40:44));
high_freq2=sum(fft_mag2(45:50));
acc1_x_peak=max(accx1);
acc1_y_peak=max(accy1);
acc1_z_peak=max(accz1);
acc2_x_peak=max(accx2);
acc2_y_peak=max(accy2);
acc2_z_peak=max(accz2);
x_cross1=0;
y_cross1=0;
z_cross1=0;
for i=1:length(accx1)-1
a1=sign(accx1(i+1));
a2=sign(accx1(i));
b=a1+a2;
if (b==0)
x_cross1=x_cross1+1;
end
a1=sign(accy1(i+1));
a2=sign(accy1(i));
b=a1+a2;
if (b==0)
y_cross1=y_cross1+1;
end
a1=sign(accz1(i+1));
a2=sign(accz1(i));
b=a1+a2;
if (b==0)
z_cross1=z_cross1+1;
end
end
x_cross2=0;
y_cross2=0;
z_cross2=0;
for i=1:length(accx2)-1
a1=sign(accx2(i+1));
a2=sign(accx2(i));
b=a1+a2;
if (b==0)
x_cross2=x_cross2+1;
end
a1=sign(accy2(i+1));
a2=sign(accy2(i));
b=a1+a2;
if (b==0)
y_cross2=y_cross2+1;
end
a1=sign(accz2(i+1));
a2=sign(accz2(i));
b=a1+a2;
if (b==0)
z_cross2=z_cross2+1;
end
end
x_crossing1=x_cross1;
y_crossing1=y_cross1;
z_crossing1=z_cross1;
x_crossing2=x_cross2;
y_crossing2=y_cross2;
z_crossing2=z_cross2;
flex1_mean=mean(flex1);
flex2_mean=mean(flex2);
flex3_mean=mean(flex3);
flex4_mean=mean(flex4);
features1=[ gyro1_x_rms gyro1_y_rms gyro1_z_rms gyro2_x_rms gyro2_y_rms gyro2_z_rms acc1_x_mean acc1_y_mean acc1_z_mean acc2_x_mean acc2_y_mean acc2_z_mean acc1_x_std acc1_y_std acc1_z_std acc2_x_std acc2_y_std acc2_z_std corr1_xy corr1_xz corr1_yz corr2_xy corr2_xz corr2_yz entropy1_x entropy1_y entropy1_z entropy2_x entropy2_y entropy2_z freq_peak1 low1_f1 low1_f2 low1_f3 mid_freq1 high_freq1 freq_peak2 low2_f1 low2_f2 low2_f3 mid_freq2 high_freq2 acc1_x_peak acc1_y_peak acc1_z_peak acc2_x_peak acc2_y_peak acc2_z_peak x_crossing1 y_crossing1 z_crossing1 x_crossing2 y_crossing2 z_crossing2 flex1_mean flex2_mean flex3_mean flex4_mean];
features=[features1];
save features features
axes(handles.axes5);
plot(abs(fftshift(fft_mag1_x)),'r')
hold on
plot(abs(fftshift(fft_mag1_y)),'g')
plot(abs(fftshift(fft_mag1_z)),'b')
plot((fft_mag1),'k')
hold off
legend('Acc x-axis FFT', 'Acc y-axis FFT', 'Acc z-axis FFT','Sum of three FTTs')
xlabel('Frequency (Hz)')
ylabel('FFT Magnitude' )
set(handles.text7, 'String', num2str(acc1_x_mean));
set(handles.text13, 'String', num2str(acc1_y_mean));
set(handles.text31, 'String', num2str(acc1_z_mean));
set(handles.text8, 'String', num2str(acc1_x_std));
set(handles.text14, 'String', num2str(acc1_y_std));
set(handles.text32, 'String', num2str(acc1_z_std));
set(handles.text9, 'String', num2str(acc1_x_peak));
set(handles.text15, 'String', num2str(acc1_y_peak));
set(handles.text33, 'String', num2str(acc1_z_peak));
set(handles.text10, 'String', num2str(acc2_x_peak));
set(handles.text16, 'String', num2str(acc2_y_peak));
set(handles.text34, 'String', num2str(acc2_z_peak));
set(handles.text11, 'String', num2str(gyro1_x_rms));
set(handles.text17, 'String', num2str(gyro1_y_rms));
set(handles.text35, 'String', num2str(gyro1_z_rms));
set(handles.text12, 'String', num2str(corr1_xy));
set(handles.text18, 'String', num2str(corr1_xz));
set(handles.text36, 'String', num2str(corr1_yz));
%draw;
% --- Executes on button press in classify_pushbutton13.
function classify_pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to classify_pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load featur.csv
feaures=mean(features);
fdata=xlsread('featur.csv');
[r c]=size(fdata);
[r1 c1]=size(features)
for jj=1:r
knn_man_sim(jj,1) =sum(abs(fdata(jj,1:58)-features(1,:)));
end
[xval xloc]=sort(knn_man_sim,'ascend');
myString =[
'alarm clock'
'beautiful '
'bed '
'bedroom '
'blackboard '
'brilliant '
'calm '
'skull '];
mylabel=[1
2
3
4
5
6
7
8
9];
[xf yf]=find(mylabel==fdata(xloc(1,1),59));
set(handles.text37, 'String', myString(xf,:));
drawnow; % Needed only if this is in a fast loop.
[xf yf]=find(mylabel==fdata(xloc(2,1),59));
set(handles.text38, 'String', myString(xf,:));
drawnow; % Needed only if this is in a fast loop.
[xf yf]=find(mylabel==fdata(xloc(3,1),59));
set(handles.text39, 'String', myString(xf,:));
drawnow; % Needed only if this is in a fast loop.

댓글 수: 4

Geoff Hayes
Geoff Hayes 2021년 6월 15일
Naseem - please copy and paste the full error message to your question. I don't see any reference to syscolorfig so I'm not sure where the error is being generated from.
Reference to non-existent field 'syscolorfig'.
Error in gui_mainfcn (line 181)
if gui_Options.syscolorfig
Error in mygui (line 42)
gui_mainfcn(gui_State, varargin{:});
Dear Geoff! This is the full error message of my code. I will be incredibly grateful for the help, thank you.
Hello Naseem! Did you find the solution to your query? If so, could you please share your steps to rectify it. I even face the same error now.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 2월 17일

0 개 추천

When the GUIDE initialization code is executed, the stored figure is retrieved from the .fig file. Then after some other things, the initialization code asks to getappdata of GUIDEOptions from the retrieved figure. The first field that it examines from the stored GUIDEOptions is named syscolorfig -- so that is the place that the code would first go wrong if there was no GUIDEOptions stored with the .fig that was loaded.
I just checked in R2016a and the code was the same back then.
So why is there no GUIDEOptions stored?
  • a different fig not created with GUIDE might have replaced the GUIDE-created .fig file
  • the GUIDE-created .fig file might have gotten corrupted somehow
  • the user might have coded creation callbacks that included clear all or other code that modifies the retrieved figure
To debug, you can
gui_hFigure = openfig('NameOfFigFile.fig');
gui_Options = getappdata(gui_hFigure,'GUIDEOptions')
and see what (if anything) shows up

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2016a

태그

질문:

2021년 6월 15일

답변:

2023년 2월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by