stroop效应matlab实验
生活随笔
收集整理的這篇文章主要介紹了
stroop效应matlab实验
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 打開matlab,打開test1.m
點擊運行,若出現選擇 更改文件夾
2 引導界面
(在這個界面,只許用戶鼠標點擊開始,其余的別亂按按鍵。 記得將打字法關掉,切換到小寫)
3 做題界面
根據顏色選擇按鍵,直到做完題。80到題
界面出現,鼠標一定要點擊下界面,不然鍵盤按鍵無效不起作用。
4結果
這里只統計正確的次數以及對應累加的時間。
2文件
function varargout = test1(varargin)
% TEST1 MATLAB code for test1.fig
% TEST1, by itself, creates a new TEST1 or raises the existing
% singleton*.
%
% H = TEST1 returns the handle to a new TEST1 or the handle to
% the existing singleton*.
%
% TEST1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TEST1.M with the given input arguments.
%
% TEST1('Property','Value',...) creates a new TEST1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before test1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to test1_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 test1
% Last Modified by GUIDE v2.5 13-Jan-2019 00:41:34
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @test1_OpeningFcn, ...
'gui_OutputFcn', @test1_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
global t0;
t0=clock;
% --- Executes just before test1 is made visible.
function test1_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 test1 (see VARARGIN)
% Choose default command line output for test1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes test1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = test1_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 [color_c] = tran_keytocolor(Key)
%判斷是否正確
color_c='';
switch Key
case 'a'
color_c='r';%紅色
case 's'
color_c='g'; %綠色
case 'd'
color_c='b';%藍色
case 'f'
color_c='y';%黃色
otherwise
warning('按鍵無效! 請選擇 a s d f 按鍵!');
end
function [num_r] = tran_leibie(idv,handles)
%判斷是否正確
num_r='';
switch idv % 判斷隨機圖的題型類
case '1'
num_r= handles.r1;
case '2'
num_r= handles.r2;
case '3'
num_r= handles.r3;
case '4'
num_r= handles.r4;
otherwise
warning('題目類型找不到!');
end
% --- Executes on key press with focus on figure1 and none of its controls.
function figure1_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.FIGURE)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
% 定義 a s d f g h j 按鍵對應顏色
% 獲取題號
all_number=80;
num=get(handles.text_num,'Value');
global word;
global color;
global randi5_16;
word={
'1', '1', '1', '1', '2', '2', '2', '2', '3', '3', '3', '3', '4', '4', '4' , '4';
'紅', '綠', '藍', '黃' ,'紅', '綠', '藍', '黃' , '我', '愛', '中', '國','洪', '皇', '攔', '濾';
};
color={'r', 'g', 'b', 'y' ,'g', 'b', 'y' , 'r' , 'r', 'y', 'b', 'g', 'g', 'b', 'y ', 'r';};
randi5_16=[1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 2 6 10 14 4 8 12 16 1 5 9 13 3 7 11 15 10 14 4 8 9 13 3 7 11 15 1 5 12 16 2 6 4 8 9 13 12 16 2 6 10 14 3 7 11 15 1 5 9 13 12 16 3 7 11 15 2 6 10 14 1 5 4 8;];
%1獲取按鍵
Key= get(gcf,'CurrentCharacter');
%按鍵轉換成顏色
color_c = tran_keytocolor(Key);
% warning(color_c);
%2 判斷是哪個隨機圖
ID=handles.randid;
if Key =='a'|| Key =='s' || Key =='d'|| Key =='f' & num<=all_number %判斷按下的是否是回車鍵
global t1;
t1=clock;
global t0;
handles.time.Value=etime(t1, t0);
handles.time.String=handles.time.Value;
t0=clock;
%2獲取當前顯示字體控件
text_show1=handles.text_show;
%3 獲取題目類別
leibie_num=word{1,ID.Value};
if leibie_num=='1'
if handles.color_temp.String==color_c & num<=all_number
num_r= handles.r1;
set(num_r, 'Value',num_r.Value+1);
set(num_r, 'String',num_r.Value);
handles.t1.Value= handles.t1.Value+ handles.time.Value;
handles.t1.String= handles.t1.Value;
end
elseif leibie_num=='2'
if handles.color_temp.String==color_c & num<=all_number
num_r= handles.r2;
set(num_r, 'Value',num_r.Value+1);
set(num_r, 'String',num_r.Value);
handles.t2.Value= handles.t2.Value+ handles.time.Value;
handles.t2.String= handles.t2.Value;
end
elseif leibie_num=='3'
if handles.color_temp.String==color_c & num<=all_number
num_r= handles.r3;
set(num_r, 'Value',num_r.Value+1);
set(num_r, 'String',num_r.Value);
handles.t3.Value= handles.t3.Value+ handles.time.Value;
handles.t3.String= handles.t3.Value;
end
elseif leibie_num=='4'
if handles.color_temp.String==color_c & num<=all_number
num_r= handles.r4;
set(num_r, 'Value',num_r.Value+1);
set(num_r, 'String',num_r.Value);
handles.t4.Value= handles.t4.Value+ handles.time.Value;
handles.t4.String= handles.t4.Value;
end
end
% 修改題號+1
if num<=all_number-1
temp1=handles.text_num;
set(temp1, 'Value',num+1);
set(temp1, 'String',num+1);
%ID1=randi(16,1);
ID1=randi5_16(temp1.Value);
set(ID, 'Value',randi5_16(temp1.Value));
set(ID, 'String',randi5_16(temp1.Value));
set(text_show1, 'String',word(2,randi5_16(temp1.Value)));
set(text_show1, 'ForegroundColor',color{randi5_16(temp1.Value)});
set(handles.color_temp, 'String',color{randi5_16(temp1.Value)});
else
temp1=handles.text_num;
set(temp1, 'Value',all_number+1);
open('result.fig')
handles.text10.Visible='on';
handles.text11.Visible='on';
handles.text14.Visible='on';
handles.text15.Visible='on';
handles.text16.Visible='on';
handles.text12.Visible='on';
handles.r1.Visible='on';
handles.r2.Visible='on';
handles.r3.Visible='on';
handles.r4.Visible='on';
handles.text8.Visible='on';
handles.t1.Visible='on';
handles.t2.Visible='on';
handles.t3.Visible='on';
handles.t4.Visible='on';
end
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)
% --- 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)
handles.text32.Visible='off';
handles.text36.Visible='off';
handles.text38.Visible='off';
handles.pushbutton2.Visible='off';
handles.text_show.Visible='on';
global t0;
t0=clock;
% --- Executes on key press with focus on pushbutton2 and none of its controls.
function pushbutton2_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
handles.text32.Visible='off';
handles.text36.Visible='off';
handles.text38.Visible='off';
handles.pushbutton2.Visible='off';
handles.text_show.Visible='on';
global t0;
t0=clock;
總結
以上是生活随笔為你收集整理的stroop效应matlab实验的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: when click one item
- 下一篇: gateway response ann