Assigning randomized values (of a linspace range using randperm) to an empty vector for posterior graphing?

1 次查看(过去 30 天)
Hello, The following code plays two beeps with a pause between them. The pause may vary within a range defined by linspace. Then randperm, randomizes the pauses. What 'c' does is combine both the functions mentioned before, in some sort of indexing device (pardon my novice-ness). When the programme ends, c displays the last randomized duration value of the range .
What I need is to graph all the user's inputs in a graph that compares them with the duration values. The problem is that when 'c' is plotted, it only shows the last duration value, as a small point in the graph.
The thing is supposed to measure the user's timing perception based on the comparison of his inputs and the duration values. It is a neuroscience experiment.
Code:
Fs=8192; %sample rate
y=sin(2*pi*2000*[0:1/Fs:0.5]); %sinewave; rate
a=linspace(0.5,1,5); %pause durations
for b=randperm(5)
c=a(b) %pause's randomization by permutation
sound(y,Fs), pause(c), sound(y,Fs), %sound production
pause,tic, pause, toc %user input; timing measures
end
I hope I was clear enough. Thanks

采纳的回答

bym
bym 2012-7-6
I have modified your code, see if this is what you are after:
clc;clear
Fs=8192; %sample rate
y=sin(2*pi*2000*[0:1/Fs:0.5]); %sinewave; rate
a=linspace(0.5,1,5); %pause durations
k = 0;
for b=randperm(5)
k = k+1; % counter
c(k) = a(b); %pause's randomization by permutation
sound(y,Fs), pause(c(k)), sound(y,Fs), %sound production
pause
tic
pause
p(k)= toc; % user input; timing measures
pause % extra pause to ensure subject is ready
end
plot(c,p,'bo',c,c,'g-')
xlim([.4 1.1])
ylim([.4 1.1])
xlabel('actual')
ylabel('percieved')
legend('response','ideal',2)
r = corrcoef(c,p);
text(.95,.6 ,num2str(r(2)))

更多回答(1 个)

Image Analyst
Image Analyst 2012-7-6
Seems like you're looking for the "scatter" function. It plots a scatterplot of one variable, like the user's inputs, against the other variable, like the duration values. Give that a try.

类别

Help CenterFile Exchange 中查找有关 Behavior and Psychophysics 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by