permutations of pseudo-random ordering for a psychology experiment

1 Ansicht (letzte 30 Tage)
Nicholas
Nicholas am 17 Okt. 2013
I need help creating code to conduct a permutation of a sequential list (vector) of pairs of 3 image types, separated by pre-specified distances, for an experiment with the following conditions:
120 trial list. Each trial is 1 image.
Type A Pairs - 20 images - images are presented twice in the list. 4 pairs, separated by 5 trials 4 pairs, separated by 10 trials 4 pairs, separated by 15 trials 4 pairs, separated by 20 trials 4 pairs, separated by 25 trials
Type B Pairs - 40 images, each image of the pair is presented once. 4 pairs, separated by 5 trials 4 pairs, separated by 10 trials 4 pairs, separated by 15 trials 4 pairs, separated by 20 trials 4 pairs, separated by 25 trials
Type C Images - 40 images, each image is presented once. These can fill the spaces between the above pairs.
Any help would be most appreciated.

Antworten (1)

Shree Harsha Kodi
Shree Harsha Kodi am 17 Jun. 2023
% Define the number of trials and pairs for each type
num_trials = 120;
num_type_a_pairs = 20;
num_type_b_pairs = 40;
num_type_c_images = 40;
% Define the separation distances for Type A and Type B pairs
type_a_separation_distances = [5, 10, 15, 20, 25];
type_b_separation_distances = [5, 10, 15, 20, 25];
% Generate the permutation
permutation = [];
% Generate Type A pairs
type_a_images = 1:num_type_a_pairs;
for j = 1:numel(type_a_separation_distances)
type_a_images = type_a_images(randperm(num_type_a_pairs));
for i = 1:2:num_type_a_pairs
pair = [type_a_images(i), type_a_images(i + 1)];
permutation = [permutation, pair, zeros(1, type_a_separation_distances(j))];
end
end
% Generate Type B pairs
type_b_images = (num_type_a_pairs * 2 + 1):(num_type_a_pairs * 2 + num_type_b_pairs);
for j = 1:numel(type_b_separation_distances)
type_b_images = type_b_images(randperm(num_type_b_pairs));
for i = 1:2:num_type_b_pairs
pair = [type_b_images(i), type_b_images(i + 1)];
permutation = [permutation, pair, zeros(1, type_b_separation_distances(j))];
end
end
% Fill the remaining spaces with Type C images
type_c_images = (num_type_a_pairs * 2 + num_type_b_pairs * 2 + 1):(num_type_a_pairs * 2 + num_type_b_pairs * 2 + num_type_c_images);
type_c_images = type_c_images(randperm(num_type_c_images));
permutation = [permutation, type_c_images];
% Pad the permutation with zeros to match the desired number of trials
permutation = [permutation, zeros(1, num_trials - numel(permutation))];
% Display the permutation
disp(permutation);
Columns 1 through 33 11 5 0 0 0 0 0 13 3 0 0 0 0 0 17 8 0 0 0 0 0 18 12 0 0 0 0 0 14 15 0 0 0 Columns 34 through 66 0 0 7 1 0 0 0 0 0 19 10 0 0 0 0 0 9 20 0 0 0 0 0 6 4 0 0 0 0 0 2 16 0 Columns 67 through 99 0 0 0 0 14 2 0 0 0 0 0 0 0 0 0 0 18 17 0 0 0 0 0 0 0 0 0 0 13 6 0 0 0 Columns 100 through 132 0 0 0 0 0 0 0 9 3 0 0 0 0 0 0 0 0 0 0 10 19 0 0 0 0 0 0 0 0 0 0 5 16 Columns 133 through 165 0 0 0 0 0 0 0 0 0 0 8 4 0 0 0 0 0 0 0 0 0 0 12 1 0 0 0 0 0 0 0 0 0 Columns 166 through 198 0 15 20 0 0 0 0 0 0 0 0 0 0 11 7 0 0 0 0 0 0 0 0 0 0 19 15 0 0 0 0 0 0 Columns 199 through 231 0 0 0 0 0 0 0 0 0 13 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 9 0 0 0 0 0 Columns 232 through 264 0 0 0 0 0 0 0 0 0 0 16 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 2 0 0 0 0 Columns 265 through 297 0 0 0 0 0 0 0 0 0 0 0 20 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 5 0 0 0 Columns 298 through 330 0 0 0 0 0 0 0 0 0 0 0 0 6 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 4 0 0 Columns 331 through 363 0 0 0 0 0 0 0 0 0 0 0 0 0 8 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 16 0 Columns 364 through 396 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 8 0 0 0 0 0 0 0 0 0 0 0 0 Columns 397 through 429 0 0 0 0 0 0 0 0 2 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 18 0 Columns 430 through 462 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 14 0 0 0 0 0 0 0 0 0 0 0 0 Columns 463 through 495 0 0 0 0 0 0 0 0 15 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 1 0 Columns 496 through 528 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 12 0 0 0 0 0 0 0 0 0 0 0 0 Columns 529 through 561 0 0 0 0 0 0 0 0 6 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 11 0 Columns 562 through 594 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 15 0 0 0 0 0 0 0 0 0 0 0 0 Columns 595 through 627 0 0 0 0 0 0 0 0 0 0 0 0 0 20 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 628 through 660 0 0 0 0 0 0 0 14 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 661 through 693 0 4 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 1 0 0 0 Columns 694 through 726 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 16 0 0 0 0 0 0 0 0 0 Columns 727 through 759 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 760 through 792 0 0 0 0 0 0 0 0 0 0 8 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 793 through 825 0 0 0 0 3 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 13 Columns 826 through 858 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 78 72 0 0 0 0 0 60 Columns 859 through 891 66 0 0 0 0 0 68 49 0 0 0 0 0 75 41 0 0 0 0 0 53 63 0 0 0 0 0 77 54 0 0 0 0 Columns 892 through 924 0 70 57 0 0 0 0 0 73 62 0 0 0 0 0 55 64 0 0 0 0 0 71 51 0 0 0 0 0 65 56 0 0 Columns 925 through 957 0 0 0 45 50 0 0 0 0 0 69 43 0 0 0 0 0 59 58 0 0 0 0 0 52 44 0 0 0 0 0 74 67 Columns 958 through 990 0 0 0 0 0 79 61 0 0 0 0 0 46 42 0 0 0 0 0 80 76 0 0 0 0 0 47 48 0 0 0 0 0 Columns 991 through 1,023 76 67 0 0 0 0 0 0 0 0 0 0 65 41 0 0 0 0 0 0 0 0 0 0 51 75 0 0 0 0 0 0 0 Columns 1,024 through 1,056 0 0 0 73 48 0 0 0 0 0 0 0 0 0 0 79 50 0 0 0 0 0 0 0 0 0 0 72 74 0 0 0 0 Columns 1,057 through 1,089 0 0 0 0 0 0 42 43 0 0 0 0 0 0 0 0 0 0 53 77 0 0 0 0 0 0 0 0 0 0 57 80 0 Columns 1,090 through 1,122 0 0 0 0 0 0 0 0 0 45 46 0 0 0 0 0 0 0 0 0 0 78 52 0 0 0 0 0 0 0 0 0 0 Columns 1,123 through 1,155 56 55 0 0 0 0 0 0 0 0 0 0 71 68 0 0 0 0 0 0 0 0 0 0 47 66 0 0 0 0 0 0 0 Columns 1,156 through 1,188 0 0 0 49 70 0 0 0 0 0 0 0 0 0 0 61 60 0 0 0 0 0 0 0 0 0 0 59 54 0 0 0 0 Columns 1,189 through 1,221 0 0 0 0 0 0 62 64 0 0 0 0 0 0 0 0 0 0 63 58 0 0 0 0 0 0 0 0 0 0 44 69 0 Columns 1,222 through 1,254 0 0 0 0 0 0 0 0 0 51 76 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42 79 0 0 0 0 0 Columns 1,255 through 1,287 0 0 0 0 0 0 0 0 0 0 58 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 43 41 0 0 0 0 Columns 1,288 through 1,320 0 0 0 0 0 0 0 0 0 0 0 47 71 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 64 0 0 0 Columns 1,321 through 1,353 0 0 0 0 0 0 0 0 0 0 0 0 53 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 55 65 0 0 Columns 1,354 through 1,386 0 0 0 0 0 0 0 0 0 0 0 0 0 45 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 72 49 0 Columns 1,387 through 1,419 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 56 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 67 Columns 1,420 through 1,452 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 63 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 Columns 1,453 through 1,485 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 75 62 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,486 through 1,518 59 69 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 74 77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,519 through 1,551 0 70 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 57 54 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,552 through 1,584 0 0 73 78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 71 49 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,585 through 1,617 0 0 0 0 0 0 0 0 52 41 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 59 79 0 Columns 1,618 through 1,650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 78 75 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,651 through 1,683 0 0 0 0 0 0 0 0 53 67 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 43 68 0 Columns 1,684 through 1,716 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 45 76 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,717 through 1,749 0 0 0 0 0 0 0 0 70 74 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65 58 0 Columns 1,750 through 1,782 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 56 64 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,783 through 1,815 0 0 0 0 0 0 0 0 73 63 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 55 57 0 Columns 1,816 through 1,848 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 42 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,849 through 1,881 0 0 0 0 0 0 0 0 47 51 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 62 46 0 Columns 1,882 through 1,914 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 50 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,915 through 1,947 0 0 0 0 0 0 0 0 72 77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 66 0 Columns 1,948 through 1,980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 80 0 0 0 0 0 0 0 0 0 0 0 0 Columns 1,981 through 2,013 0 0 0 0 0 0 0 0 69 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 66 0 Columns 2,014 through 2,046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 72 52 0 0 0 0 0 0 0 Columns 2,047 through 2,079 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 55 44 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,080 through 2,112 0 0 0 0 0 0 0 0 0 0 0 0 54 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,113 through 2,145 0 0 0 0 0 0 47 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,146 through 2,178 59 56 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 53 50 0 0 0 0 Columns 2,179 through 2,211 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 43 0 0 0 0 0 0 0 0 0 0 Columns 2,212 through 2,244 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 49 68 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,245 through 2,277 0 0 0 0 0 0 0 0 0 57 77 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,278 through 2,310 0 0 0 64 42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 67 76 0 Columns 2,311 through 2,343 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 70 0 0 0 0 0 0 0 Columns 2,344 through 2,376 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 78 46 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,377 through 2,409 0 0 0 0 0 0 0 0 0 0 0 0 51 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,410 through 2,442 0 0 0 0 0 0 74 71 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,443 through 2,475 69 62 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 75 61 0 0 0 0 Columns 2,476 through 2,508 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 79 63 0 0 0 0 0 0 0 0 0 0 Columns 2,509 through 2,541 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 73 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 2,542 through 2,574 0 0 0 0 0 0 0 0 0 127 148 159 121 152 151 138 155 143 135 146 133 149 153 140 157 128 130 123 139 131 134 125 150 Columns 2,575 through 2,590 158 144 122 132 136 160 137 126 124 154 129 141 156 145 147 142

Kategorien

Mehr zu Psychology finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by