College Student in need of simple Matlab advice

So I'm trying to run a basic sound experiment that has a participant hear a sound at a specific frequency, and then playing 10-20 more sounds, some of them being the same as the first frequency, some being different. For every sound that matches the initial sound, the participant will press a 'same' button on the screen. I've set up the basic code but I'm having trouble with data aquisition and getting the sounds to actually play (for the data aquisition I just need a 0 or 1 for each sound played, that is, if the first sound is identical to the original tone, the participant presses 'same' and the output records a 1; if the first sound is different than the original tone, 'same' is not clicked and the output records a 0). If anyone can give me any advice or pointers it would be greatly appreciated, I'll copy the code down below. As of now, when i try to input frequencies in the range of 400-1200 hz a high pitched weird sound plays. I want to give advanced thanks to anyone that posts anything helpful here. Cheers
output=0;

background = figure('NumberTitle','off','Toolbar','None','MenuBar','none', ...
    'Name','Experiment','Color',[0 0 0],'Units','normalized','Position',[0 0 1 1]);

outbutton=uicontrol('style','pushbutton','units','normalized','ButtonDownFcn',...
    'outputfunc','position',[.46,.5,.08,.035],'string','Same','fontsize',14, 'visible','on');


numtrials=20;

%sounds=xxx

isi=1;

t=[0:1/8192:1];

z=sin(2*pi*t);


f=[i think this is where i put the frequency order];



for j=1:numtrials

  
    sound(z,f(j));
    
    pause(isi);

  data(j)=output;
  
output=0;
end

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited June 2007
    you're setting the fs for soundcard to play at, not setting the frequency of the sin wave. You'll need to generate all the different frequency tones and play them all back at fs = 8192.
  • edited June 2007
    how do i create the different frequencies in the context of having them play in a sequence, and making sure there is a pause in between tones. I know how to create general tones at specific frequencies but I'm having a hard time figuring out how to make them with regards to this simple experiment. ANY MORE ADVICE WOULD BE GREATLY APPRECIATED, THANKS!
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited June 2007
    [php]
    f = [a bunch of frequencies];
    fs = [a sampling frequency, must be higher than 2* your highest frequency];
    t = 0:1/fs:1;
    for i=1:length(f)
    x = sin(2*pi*f(i)*t);
    soundsc(x,fs);
    pause();
    end
    [/php]
Sign In or Register to comment.