フィルターのクリア

N-back function, same letter repeats more than 4 times

2 ビュー (過去 30 日間)
Selen Soylu
Selen Soylu 2023 年 2 月 10 日
コメント済み: Voss 2023 年 2 月 12 日
function [trial, trial_letters] = my_N_back(trial_count,hit_count,N)
alphabet = ["B","C","D","F","G","H","J","K","L","M","N","P","Q" "R","S","T","V","Y","W","Z"];
false_alarm = zeros(1,trial_count - hit_count);
hit = ones(1,hit_count);
no_hit = 1; %determine where there shall be no hits (first two indices)
max_no_hit_N = max(N,no_hit);
trial = [false_alarm(1:max_no_hit_N),Shuffle([false_alarm(max_no_hit_N+1:end), hit])];
%When false_alarm(1:max_no_hit_N) is called, [0 0 ] is the ans, so the
%first two index, no hits and this is determined by the max_not_hit_N.
trial_letters = strings(1,trial_count);
shuffle_alph = Shuffle(alphabet);
trial_letters(1:max_no_hit_N) = shuffle_alph(1:max_no_hit_N); %determine the first two.
last_letter = '';
count_last_letter = 0;
for i= N+1:length(trial)
if trial(i) == 0
rand_letter = alphabet(randi(numel(alphabet),1,1));
while rand_letter == last_letter
rand_letter = alphabet(randi(numel(alphabet)));
end
last_letter = rand_letter;
count_last_letter = 1;
trial_letters(i) = rand_letter;
else
if trial_letters(i-N) == last_letter
count_last_letter = count_last_letter + 1;
if count_last_letter >= 3
rand_letter = alphabet(randi(numel(alphabet),1,1));
while rand_letter == last_letter
rand_letter = alphabet(randi(numel(alphabet)));
end
last_letter = rand_letter;
count_last_letter = 1;
trial_letters(i) = rand_letter;
else
trial_letters(i) = trial_letters(i-N);
end
else
last_letter = trial_letters(i-N);
count_last_letter = 1;
trial_letters(i) = trial_letters(i-N);
end
end
end
end
>This function is supposed to generate a string array and a binary vector when given the input of trial numbers, hit ratio and the N-back specification.
i.e. With the input of 10 as trial numbers, 5 as hit trials and N as 1: the output could be [A B B B C D D E E E ] the binary vector trial should be
[ 0 0 1 1 0 0 1 0 1 1].
But, the trials and trial_letters do not match. The trial vector has ones, but the trial_letters indicate no hit trial. The function needs to be used with N = 2 and N = 3 as well, and same issue happens with that too. Mostly the mid one, so there are ones in the trial output, where there are not hits in the string array.
  6 件のコメント
Selen Soylu
Selen Soylu 2023 年 2 月 12 日
I manually checked and compared
Voss
Voss 2023 年 2 月 12 日
Please give an example of correct output and how you know it's correct.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangePsychology についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by