フィルターのクリア

how to finds consecutive numbers in an array

4 ビュー (過去 30 日間)
Douwe Horsthui
Douwe Horsthui 2019 年 9 月 21 日
編集済み: Douwe Horsthui 2019 年 9 月 21 日
Hi everyone,
I have a question about finding consecutive numbers in a matlab array.
Currently my script imports .log files that are created by a experiment run on Presentation. In the array this creates I see all of the trigger codes, but I only want to know when a specific trigger code happens followed by a different trigger code (button press)
This is what I came up with so far but I am stuck.
clear all
dir='C:\Users\Desktop\paradigm\'
total_blocks = 1 %amount of blocks
data1 = []
for blocks=1:total_blocks
[x] =importPresentationLog([dir '10049-Entrain_Vis' num2str(blocks) '.txt']); %importing logfile
data1 = [data1, x] % all info from all the logfiles go here.
end
No_of_Trials=length(data1);
for i=1:No_of_Trials
trigger{i}=(data1(:,i).code);
Time{i}=(data1(:,i).time);
end
[INDEX_CODE42]=find(strcmp(trigger,'42')==1) %%finding the definde trigger (42) and creating an index
However I want to look specifically for '42' followed by '100' OR '42' followed by any possible trigger followed by '100'
Next42=trigger(INDEX_CODE42+1); %gives the triggers following the previous one (42)
code100=[INDEX_CODE100]
NextNext42=trigger(INDEX_CODE42+2)%gives the second triggers following the previous one (42)
Time42=Time(INDEX_CODE42+1);
Time42x=Time(INDEX_CODE42)
RT = cellfun(@minus,Time42,Time42x,'UniformOutput',false)
This part works but since it includes every 42 trigger and not only the correct ones ( the ones followed by a button press) I include all the trials that didn't get a respons.
I hope someone is able to help me out with this.
Thank you so much!
  3 件のコメント
Douwe Horsthui
Douwe Horsthui 2019 年 9 月 21 日
I have added now the importPresentationLog() function, but the website doesn't allow me to upload the .log file
Douwe Horsthui
Douwe Horsthui 2019 年 9 月 21 日
so instead I changed the .log file in a .txt file. Hopefully this works the same in the script

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by