Matlab利用PsychToolBox收集的反应数据绘图

上一篇利用PsychToolBox呈现刺激并收集被试者的反应时间、判断,得到的结果绘图,如下图是我实验140次得到的结果图:
在这里插入图片描述

代码:

clear
load mask_result4.mat
%整理数据
Acc = stats.response{2};
RT = stats.response{1};
Mask_pool = stats.Masks(1:length(Acc));%获取140试次对应mask的值
SOA_pool = stats.SOAs(1:length(Acc));  %获取140试次对应SOA的值

type_soa = unique(SOA_pool);
type_mask = unique(Mask_pool);         %返回不包含重复项的排序后的数据
for soa = 1:length(type_soa)
    for mask = 1:length(type_mask)
        idx = find((SOA_pool == type_soa(soa))&(Mask_pool == type_mask(mask)));%取出不同mask下对应试次
        %如本次实验中 当mask=1 soa=1idx=6 为第六试次;
        rt_now = RT(idx);              %获取当前试次的反应时间 本次实验时间为0.6789
        acc_now = Acc(idx);            %获取当前试次的正确与否 本次实验为1
        acc_summary(soa,mask) = mean(acc_now); %(soa,mask)对应的准确率数组均值
        rt_summary(soa,mask) = mean(rt_now);   %(soa,nask)对应的反应时间数据均值
        error_rt(soa,mask) = std(rt_now)/sqrt(length(rt_now));%反应时的标准差
    end
end

%绘图
figure 
soas = [6.1:6.1:24.4000];
subplot(1,2,1);
p1 = plot(soas,acc_summary(:,1),'--k');%绘制虚心
hold on
p2 = plot(soas,acc_summary(:,2),'k');
colors = ['rgbm'];
for i = 1:4
    scatter(soas(i),acc_summary(i,:),50,colors(i),"filled");%节点绘制颜色大小为50
    %scatter(x,y,sz,c)
    %scatter(___,'filled')
end
yline(0.33,'--');					    %准确率均值
hold off
legend([p1,p2],{'without mask','with mask'},'Location','best');
ylabel('performance')
xlabel('SOA(ms)')
xticks(soas)            				%设置x轴坐标点
text(20,0.5,'n=144');    				%设置文字
xlim([0,30]);          					%设置x轴坐标范围

%反映时间绘制
soas = [6.1:6.1:24.4000];
subplot(1,2,2);
p3 = errorbar(soas,rt_summary(:,1),error_rt(:,1),'--k');
%创建 y 中数据的线图,并在每个数据点处绘制一个垂直误差条
%err 中的值确定数据点上方和下方的每个误差条的长度
%errorbar(x,y,neg,pos)
hold on
p4 = errorbar(soas,rt_summary(:,2),error_rt(:,2),'k');
for i = 1:4
    scatter(soas(i),rt_summary(i,:),20,colors(i),"filled");
end
hold off
legend([p3,p4],{'with mask','without mask'},'Location','best');
ylabel('RT');
xlabel('SOA(ms)');
xticks(soas);
text(20,0.9,'n=144');
xlim([0,30]);
sgtitle('Joey Now');   %标题
saveas(gca,'wu.png');  %保存图片

mask_result4.mat文件网盘:链接:https://pan.baidu.com/s/1JEIaJqK9PLzsALd1GRvYFA
提取码:xqyq

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

好的!文西

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值