Here is my code:
function varargout = untitled2(varargin)% UNTITLED2 MATLAB code for untitled2.fig% UNTITLED2, by itself, creates a new UNTITLED2 or raises the existing% singleton*.%% H = UNTITLED2 returns the handle to a new UNTITLED2 or the handle to% the existing singleton*.%% UNTITLED2('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in UNTITLED2.M with the given input arguments.%% UNTITLED2('Property','Value',...) creates a new UNTITLED2 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before untitled2_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to untitled2_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 untitled2% Last Modified by GUIDE v2.5 04-Jun-2017 13:40:49% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @untitled2_OpeningFcn, ... 'gui_OutputFcn', @untitled2_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 untitled2 is made visible.function untitled2_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 untitled2 (see VARARGIN)% Choose default command line output for untitled2handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes untitled2 wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = untitled2_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 structurevarargout{1} = handles.output;pic=imread('dir.jpg');image(pic);% --- 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)clear all;[ocean,fs]=audioread('ocean2.mp3');soundsc(ocean,fs)m = mobiledev; swing=0;pause(5)pic=imread('START.jpg');image(pic); m.Logging = 1; pause(3);m.Logging=0;[or, tor] = orientlog(m);x = or(:,2);c=x(end); y = or(:,3); d=y(end);if c<-5pic=imread('home1.jpg');image(pic);pause(5)endif c>-5&&d>5pic=imread('home2.jpg');image(pic);pause(5)endif c>5&&d<5pic=imread('home3.jpg');image(pic);pause(5)endif c>-5&&c<5&&d<-5pic=imread('home4.jpg');image(pic);pause(5);end% --- 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)clear all;[ocean,fs]=audioread('ocean2.mp3');soundsc(ocean,fs)pic=imread('rod2.jpg');image(pic);clear m; %每次開始前清除m中資料 m = mobiledev; m.Logging = 1; pause(2); %有2秒時間取值m.Logging = 0;[ac, tac] = accellog(m); % accellogx = ac(:,1); %只取X向量值k=max(x); %取的所有x中抓出MAX值if max(x)>10&&max(x)<13 %每下一個if皆包含在前面的if中 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('1.jpg'); image(pic); pause(0.5); endif max(x)>13&&max(x)<16 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('2.jpg'); image(pic); pause(0.5); endif max(x)>16&&max(x)<19 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('3.jpg'); image(pic); pause(0.5); endif max(x)>19&&max(x)<22 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('4.jpg'); image(pic); pause(0.5); endif max(x)>22&&max(x)<25 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('5.jpg'); image(pic); pause(0.5); endif max(x)>25&&max(x)<28 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('6.jpg'); image(pic); pause(0.6); endif max(x)>28&&max(x)<31 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('7.jpg'); image(pic); pause(0.6); endif max(x)>31&&max(x)<34 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('8.jpg'); image(pic); pause(0.7); endif max(x)>34&&max(x)<37 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('9.jpg'); image(pic); pause(0.7); end if max(x)>37&&max(x)<40 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('10.jpg'); image(pic); pause(0.8); end if max(x)>40&&max(x)<43 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('11.jpg'); image(pic); pause(0.8); endif max(x)>43&&max(x)<45 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('12.jpg'); image(pic); pause(0.8); endif max(x)>45&&max(x)<48 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('13.jpg'); image(pic); pause(1); endif max(x)>48&&max(x)<51 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('14.jpg'); image(pic); pause(1); end if max(x)>51&&max(x)<54 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('15.jpg'); image(pic); pause(1.5); end if max(x)>54 pic=imread('rod3.jpg'); image(pic); pause(3); pic=imread('16.jpg'); image(pic); pause(1); end assignin('base','k',k);load_system('test'); %進入simulink再傳回sim('test'); a= max(a);pic=imread('rate.jpg');image(pic);pause(2);if a==1 pic=imread('last4.jpg'); image(pic); pause(2); elseif a==2 pic=imread('last3.jpg'); image(pic); pause(2); elseif a==3 pic=imread('last2.jpg'); image(pic); pause(2); elseif a==4 pic=imread('last1.jpg'); image(pic); pause(2); end