MATLAB: complex graph with multiple inputs
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I am running a program through MATLAB that involves user response to generated sound. There are three sets of trials, at three different frequencies. Within each frequency, the break-down of the trials is a bit complicated:
-each frequency has a maximum sound level/intensity that is set at the beginning of each run through the experiment -each frequency will be tested a number of times with random trials; the program automatically generates a number of sound files starting at the maximum level and declining by a preset limit to a preset minimum. All these levels are variable, and we plan on running the experiment multiple times with different levels.
So, essentially, the experiment consists of three "parts," and within each part there is a variable number of trials at different sound levels, requiring a "yes" or "no" response.
Now, the experiment itself is already designed, and works perfectly. It is currently set up so a diary file will contain all the input data for later examination. However, I am trying to automate this step a little bit; I have used MATLAB fairly extensively, but have never used its various graphing/plotting functions.
What I want to do is create a graph with sound level/intensity on the X-axis, ranging from the minimum intensity to the maximum intensity (which most likely will be 60dB to 110dB), and the percent correct responses on the Y-axis (the user prompt is simply yes/no, and every yes response will be marked as correct, every no response as incorrect). On this graph I want a line for the responses at each frequency.
Is this possible to do on MATLAB, or is it a bit too complicated? I've been fiddling around all day with it, but am having trouble with the graphing functions. The script is rather long, so I can't provide the whole thing, but the part that should be relevant is as follows:
for trial = 1 : NUM_TRIALS
SPLs_presn_order = SPLs ( randperm(NUM_SPLS) );
presentation = 1;
yes = 0;
no = 0;
while presentation <= NUM_SPLS
SPL_reduction = speaker_max_SPL_this_freq - SPLs_presn_order(presentation);
factor = 10.0 ^ ( SPL_reduction/20 );
stim = sig / factor;
delay_before_onset = MIN_DELAY + rand * (MAX_DELAY-MIN_DELAY);
pause ( delay_before_onset );
onset_str = datestr ( now );
my_play_sound ( stim, FS );
question = 'Did subject report hearing the sound?';
titl = 'What actually happened?';
button = questdlg ( question, titl, 'YES', 'NO', 'Uh Oh', 'Uh Oh' );
if strcmp ( button, 'Uh Oh' ) == 1
question = 'What now?';
titl = 'How bad is it?';
button = questdlg ( question, titl, 'Abort Whole Run', 'Replay Last Sound', 'Replay Last Sound' );
if strcmp ( button, 'Abort Whole Run' ) == 1
for j = 1 : 10
disp ( ' -- RUN ABORTED --' );
end;
diary off;
return;
end;
end
switch button
case 'YES'
yes = yes+1;
case 'NO'
no = no+1;
end
out_str = sprintf ( '%s %6.0f Hz %3.0f %s ' ,...
onset_str, frequency, SPLs_presn_order(presentation), button );
disp ( out_str );
if strcmp ( button, 'Replay Last Sound' ) == 0
presentation = presentation + 1;
end;
end;
disp ( ' ' ); % skip a line in output
end;
As you can see, at the moment there are no graphing commands, I don't know how to go about it. The way it is currently set up, every time they press the button 'YES,' it adds one to the variable 'yes,' and same for 'NO.' I figure from there it is easy to create an equation to calculate the percent correct responses. But how do I go about creating a plot with a line for each frequency?
Thanks, --R
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!