Average matrices by limiting the content
Mostrar comentarios más antiguos
I have two columns (Block,1,2,3; and Type, 6,7,8,12,13,14). Also, I have 10 columns of Reaction times for 10 people. The number of rows is 399 for each block, meaning 399 words in each block (399*3 total). I need to average all the 6 types for each block separately for all columns. I have come up with the following script for Block 1 , Type 6 but it seems it does not select only the reaction times in the first block and type 6.
for k=1:size(Block,1)
for r=1:size(Block,2)
if Block(k,r)==1 && Type(k,r)==6
b=0;
for m=1:size(RTc,1)
for n=1:size(RTc,2)
M_type6=mean(RTc,'omitnan');
b=b+1;
end
end
else
;
end
end
end
4 comentarios
Bob Thompson
el 4 de Abr. de 2018
I want to make sure I'm correctly understanding what you're looking to end up with. Based on the first two for loops you're going to run through your Block from left to right, top to bottom, allowing you to examine all elements of Block individually.
for k=1:size(Block,1) % Selects each row of Block
for r=1:size(Block,2) % Selects each column of Block
if Block(k,r)==1 && Type(k,r)==6 % Status check to look for block 1, type
% 6 elements. Is type also 399x3?
b=0; % Initialization, I'm assuming
for m=1:size(RTc,1) % How does RTc get limited by your if statement.
% Currently these loops will only run when Block is 1
% and Type is 6, but there is no further restriction
% on the values of RTc, so all values of RTc will be
% evaluated (from what I can currently see of your
% code).
for n=1:size(RTc,2)
M_type6=mean(RTc,'omitnan');
b=b+1;
end
end
end
end
end
Elaheh
el 4 de Abr. de 2018
Bob Thompson
el 4 de Abr. de 2018
Could you give examples of how your data is organized? I'm unsure still how things are related.
Elaheh
el 4 de Abr. de 2018
Respuestas (1)
Elaheh
el 4 de Abr. de 2018
0 votos
Categorías
Más información sobre Programmatic Model Editing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!