To talk on Icrontic, just register!

It only takes 30 seconds.

Have an account? Sign in:

Forgot?
petersternfeld
New to the neighborhood
petersternfeld
3 Posts

Experiment matlab help

Hello everybody, I'm working on a cognitive science experiment and needed a little help writing some matlab code. Its a basic listening experiment where the participant hears a tone at a frequency of 800 hz followed by a string of 30 tones that vary in frequency. The subject uses a slider that starts at the middle (800hz) and moves it to the relative location up or down on the slider that they think corresponds to the new frequency. So if the next tone was 900 hz, they would move the slider up, say halfway. If it was 775 hz they will pull the slider to a little under the original halfway mark.

I have some basic code for a slider but was wondering how I could first put lines on the side displaying intervals on the slider (if the middle is 800, have a long line denoting this as well as shorter lines marking 4 - 50 hz intervals both up and down). I also have basic code for collecting data but it doesn't seem to be working. I have a 2 x 32 matrix, the two rows representing two trials for the experiment and the first two columns denoting which subject number and which trial number respectively. For every sound, I would like the program to record where the slider is (with respect to the middle line of the slider) and save that number into the exp_data file. If anyone can take a look at this code and offer some advice, it would be greatly appreciated. Thanks!



PHP Code:
clear allclose all;
 
background figure('NumberTitle','off','Toolbar','None','MenuBar','none', ...
'Name','Experiment','Color',[0 0 0],'Units','normalized','Position',[0 0 1 1]);
%
instructions;
 
inst = {'Thank you for participating in this experiment!' 
'';
'Please read these instructions very carefully!!';
'' ;
''
'Click OK when you are ready to begin.'
;%these are the instructions
};
inst2 = {'Part One of this experiment is now complete.' 
'';
'The experimenter will give you instructions for the second part of the experiment';
 
'';
%
these are the instructions
};
instruction msgbox(inst,'Instructions'); %calls an instruction message box
uiwait 
(instruction) %Tells the system to wait until the instruction box is closed
 
 
outbutton
=uicontrol('style','radio','units','normalized',...
'position',[0 0 1 1],'string','Same','fontsize',20'visible','off');
 
outslider uicontrol('style','slider','parent',background,'units','normalized','sliderstep',[0.1 0.1], ...'position',[0.45 0.35 0.1 0.3],'backgroundcolor',[1 1 1]); %create a slider 
 
set
(outslider,'value',0.5); % set a slider value in the middle
 
numtrials
=30;
 
fs=8192;
dur=0.5;
isi=2;
t=[0:1/fs:dur];
 
 
fname 'exp_data.mat';
if 
exist(fname,'file')
disp('load file');
load(fname);
partno size(expdata,1)/1;
else
currentf=800;
f=[600 600 650 650 700 700 750 750 775 775 785 785 800 800 800 800 800 800 815 815 825 825 850 850 900 900 950 950 1000 1000];
rand('seed',123456);
stimorder1=randsample(length(f),30);
stimorder2=randsample(length(f),30);
expdata = [];
partno 1;
end
 
z1
=sin(2*pi*t*currentf);
 
for 
niter 1:4
sound
(z1,fs);
pause(dur+isi*2);
endfor 
j=1:numtrials
 
 
set
(outbutton,'value',0); drawnow();
%
pause(.1); %pause(isi/6);
z=sin(2*pi*t*f(stimorder1(j)));
 
 
waitforbuttonpress
 
set
(outbutton,'visible','on');
 
stimorder stimorder1;
for 
niter 1:2
sound
(z,fs);
 
pause(dur+isi);
 
data(j)=get(outbutton,'value');
data2(j)=get(outslider,'value'); % get a slider value
 
 
end
expdata 
= [expdata ; [ partno niter data ] ];
if 
niter == 1
instruction 
msgbox(inst2,'Instructions #2'); %calls an instruction message box
uiwait 
(instruction) %Tells the system to wait until the instruction box is closed
 
waitforbuttonpress
 
for niter 1:4
sound
(z1,fs);
pause(dur+isi*2);
end
end
 
waitforbuttonpress
 
stimorder 
stimorder2;
end
 
save
(fname,'f','currentf','stimorder1','stimorder2','expdata');
 
close(background); 
Kwitko
Sheriff of Dicktown
Kwitko
6,525 Posts

» Subscriber

Moved to Matlab help forum
__________________ "Is it not cruel to let our city die by degrees, stripped of all her proud monuments, until there will be nothing left of all her history and beauty to inspire our children?... this is the time to take a stand, to reverse the tide, so that we won't all end up in a uniform world of steel and glass boxes." - Jacqueline Kennedy Onassis


Similar Threads
Thread Thread Starter Forum Replies Last Post
matlab solver - grid search Dina Matlab Help 8 6 Jun 2007 5:29pm
MatLab problem - inline function zero finder PGolasze Matlab Help 4 10 May 2007 12:38am
Need matlab help urgently shermaine Matlab Help 3 10 Nov 2006 1:00am
MATLAB code help please.... jennifer22cute Matlab Help 0 18 Sep 2006 8:53pm
MATLAB help= jpeg to avi dalisay Web & Digital Media 0 13 May 2006 5:03pm

Go Back   Icrontic Forums > Tech: Software > General Software > Matlab Help
Jump to
This Thread Search this Thread
Search this Thread:

Advanced Search


Current time: 2:14am (GMT)
Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Get Vanilla instead. Trust me.