csv數(shù)據(jù)matlab批處理

% ------------------------------
% Matlab csv數(shù)據(jù)批量預(yù)處理輸出至Excel
% 時(shí)間:2022年8月28日
% 所需軟件代碼:Matlab R2020a
% 本代碼版本:3.00
% 程序員:wishing
% ------------------------------
%% 初始化
% 清理運(yùn)行環(huán)境
clearvars
clc
%% 單個(gè)文件處理
%% 目標(biāo):
% 1.篩選出每個(gè)被試4種速度條件下的數(shù)據(jù)(無(wú)應(yīng)答率还惠,正確率泞莉,反應(yīng)時(shí),最快10%平均反應(yīng)時(shí)),需計(jì)算出結(jié)果寞秃,最終每個(gè)被試有四中速度下的結(jié)果瑰枫,每種速度下有四個(gè)值踱葛。
% 2.整理成RW狀態(tài)下speed1(+-0.5)/speed2(+-1)/speed3(+-1.5)/speed4(+-2)下的所有被試的數(shù)據(jù)。(RW下四個(gè)Sheet,SD下四個(gè)sheet光坝,每個(gè)sheet下每個(gè)被試有四個(gè)值)

%% 循環(huán)處理
for No = 10 : 37
        filename_RW = string(append('D:\desk\speed\data_1\behavior\RW','\','1',string(No),'.csv'));%文件位置尸诽,制作NO循環(huán)
        filename_SD = string(append('D:\desk\speed\data_1\behavior\SD','\','2',string(No),'.csv'));%文件位置,制作NO循環(huán)
       %% 數(shù)據(jù)準(zhǔn)備
        data_RW = readmatrix(filename_RW); % 導(dǎo)入成矩陣
        data_SD = readmatrix(filename_SD);
        A = data_RW(:,[2 18 19 20]);%提取2,18,19,20列組成新數(shù)組盯另,分別代表speed性含,res_keys,res_corr,res_rt
        B = data_SD(:,[2 18 19 20]);
        R_speed_1 = A(A(:,1)==7.5|A(:,1)==8.5,:);% 篩選出speed1,2,3,4的數(shù)據(jù)
        R_speed_2 = A(A(:,1)==7|A(:,1)==9,:);
        R_speed_3 = A(A(:,1)==6.5|A(:,1)==9.5,:);
        R_speed_4 = A(A(:,1)==6|A(:,1)==10,:);
        S_speed_1 = B(B(:,1)==7.5|B(:,1)==8.5,:);
        S_speed_2 = B(B(:,1)==7|B(:,1)==9,:);
        S_speed_3 = B(B(:,1)==6.5|B(:,1)==9.5,:);
        S_speed_4 = B(B(:,1)==6|B(:,1)==10,:);
         %% 計(jì)算指標(biāo)
         %RW
         R_speed_1_norate = numel(find(isnan(R_speed_1(:,2))))/14;%計(jì)算無(wú)應(yīng)答率,nan個(gè)數(shù)/14
         R_speed_1_corate = sum(R_speed_1(:,3))/14;%計(jì)算正確率鸳惯,1求和/14
         R_speed_1_meanrt = mean(R_speed_1(:,4),'omitnan');%計(jì)算均值商蕴,忽略nan
         R_speed_1_fastrt = min(R_speed_1(:,4));%最快10%,14個(gè)中就是最小值
         R_speed_2_norate = numel(find(isnan(R_speed_2(:,2))))/14;
         R_speed_2_corate = sum(R_speed_2(:,3))/14;
         R_speed_2_meanrt = mean(R_speed_2(:,4),'omitnan');
         R_speed_2_fastrt = min(R_speed_2(:,4));
         R_speed_3_norate = numel(find(isnan(R_speed_3(:,2))))/14;
         R_speed_3_corate = sum(R_speed_3(:,3))/14;
         R_speed_3_meanrt = mean(R_speed_3(:,4),'omitnan');
         R_speed_3_fastrt = min(R_speed_3(:,4));
         R_speed_4_norate = numel(find(isnan(R_speed_4(:,2))))/14;
         R_speed_4_corate = sum(R_speed_4(:,3))/14;
         R_speed_4_meanrt = mean(R_speed_4(:,4),'omitnan');
         R_speed_4_fastrt = min(R_speed_4(:,4));
         %SD
         S_speed_1_norate = numel(find(isnan(S_speed_1(:,2))))/14;
         S_speed_1_corate = sum(S_speed_1(:,3))/14;
         S_speed_1_meanrt = mean(S_speed_1(:,4),'omitnan'); 
         S_speed_1_fastrt = min(S_speed_1(:,4));
         S_speed_2_norate = numel(find(isnan(S_speed_2(:,2))))/14;
         S_speed_2_corate = sum(S_speed_2(:,3))/14;
         S_speed_2_meanrt = mean(S_speed_2(:,4),'omitnan');
         S_speed_2_fastrt = min(S_speed_2(:,4));
         S_speed_3_norate = numel(find(isnan(S_speed_3(:,2))))/14;
         S_speed_3_corate = sum(S_speed_3(:,3))/14;
         S_speed_3_meanrt = mean(S_speed_3(:,4),'omitnan');
         S_speed_3_fastrt = min(S_speed_3(:,4));
         S_speed_4_norate = numel(find(isnan(S_speed_4(:,2))))/14;
         S_speed_4_corate = sum(S_speed_4(:,3))/14;
         S_speed_4_meanrt = mean(S_speed_4(:,4),'omitnan');
         S_speed_4_fastrt = min(S_speed_4(:,4));     
        %% 輸出結(jié)果
     % RW
      writematrix([R_speed_1_norate R_speed_1_corate R_speed_1_meanrt R_speed_1_fastrt],'RW_speed.xlsx','sheet',1,'Range',string(append('A',string(No),':D',string(No))));%循環(huán)寫入表格
      writematrix([R_speed_2_norate R_speed_2_corate R_speed_2_meanrt R_speed_2_fastrt],'RW_speed.xlsx','sheet',2,'Range',string(append('A',string(No),':D',string(No))));
      writematrix([R_speed_3_norate R_speed_3_corate R_speed_3_meanrt R_speed_3_fastrt],'RW_speed.xlsx','sheet',3,'Range',string(append('A',string(No),':D',string(No))));
      writematrix([R_speed_4_norate R_speed_4_corate R_speed_4_meanrt R_speed_4_fastrt],'RW_speed.xlsx','sheet',4,'Range',string(append('A',string(No),':D',string(No))));
     % SD
      writematrix([S_speed_1_norate S_speed_1_corate S_speed_1_meanrt S_speed_1_fastrt],'SD_speed.xlsx','sheet',1,'Range',string(append('A',string(No),':D',string(No))));
      writematrix([S_speed_2_norate S_speed_2_corate S_speed_2_meanrt S_speed_2_fastrt],'SD_speed.xlsx','sheet',2,'Range',string(append('A',string(No),':D',string(No))));
      writematrix([S_speed_3_norate S_speed_3_corate S_speed_3_meanrt S_speed_3_fastrt],'SD_speed.xlsx','sheet',3,'Range',string(append('A',string(No),':D',string(No))));
      writematrix([S_speed_4_norate S_speed_4_corate S_speed_4_meanrt S_speed_4_fastrt],'SD_speed.xlsx','sheet',4,'Range',string(append('A',string(No),':D',string(No))));
end


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末芝发,一起剝皮案震驚了整個(gè)濱河市绪商,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌辅鲸,老刑警劉巖格郁,帶你破解...
    沈念sama閱讀 211,639評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡例书,警方通過(guò)查閱死者的電腦和手機(jī)锣尉,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,277評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)雾叭,“玉大人悟耘,你說(shuō)我怎么就攤上這事≈” “怎么了暂幼?”我有些...
    開封第一講書人閱讀 157,221評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)移迫。 經(jīng)常有香客問(wèn)我旺嬉,道長(zhǎng),這世上最難降的妖魔是什么厨埋? 我笑而不...
    開封第一講書人閱讀 56,474評(píng)論 1 283
  • 正文 為了忘掉前任邪媳,我火速辦了婚禮,結(jié)果婚禮上荡陷,老公的妹妹穿的比我還像新娘雨效。我一直安慰自己,他們只是感情好废赞,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,570評(píng)論 6 386
  • 文/花漫 我一把揭開白布徽龟。 她就那樣靜靜地躺著,像睡著了一般唉地。 火紅的嫁衣襯著肌膚如雪据悔。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,816評(píng)論 1 290
  • 那天耘沼,我揣著相機(jī)與錄音极颓,去河邊找鬼。 笑死群嗤,一個(gè)胖子當(dāng)著我的面吹牛菠隆,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播狂秘,決...
    沈念sama閱讀 38,957評(píng)論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼骇径,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了赃绊?” 一聲冷哼從身側(cè)響起既峡,我...
    開封第一講書人閱讀 37,718評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤羡榴,失蹤者是張志新(化名)和其女友劉穎碧查,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,176評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡忠售,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,511評(píng)論 2 327
  • 正文 我和宋清朗相戀三年传惠,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片稻扬。...
    茶點(diǎn)故事閱讀 38,646評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡卦方,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出泰佳,到底是詐尸還是另有隱情盼砍,我是刑警寧澤,帶...
    沈念sama閱讀 34,322評(píng)論 4 330
  • 正文 年R本政府宣布逝她,位于F島的核電站浇坐,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏黔宛。R本人自食惡果不足惜近刘,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,934評(píng)論 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望臀晃。 院中可真熱鬧觉渴,春花似錦、人聲如沸徽惋。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,755評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)寂曹。三九已至哎迄,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間隆圆,已是汗流浹背漱挚。 一陣腳步聲響...
    開封第一講書人閱讀 31,987評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留渺氧,地道東北人旨涝。 一個(gè)月前我還...
    沈念sama閱讀 46,358評(píng)論 2 360
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像侣背,于是被迫代替她去往敵國(guó)和親白华。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,514評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容