For loop index problem
8 次查看(过去 30 天)
显示 更早的评论
I have 3 variables called all_data_sess1, all_data_sess2 and all_data_sess3 which each contain a 216x8 matrix. When I run the following part of code below, the values for these variables change to just 216 and the matrix is gone, which I don't want. There are 216 rows and I want my for loop to go through each row, which is why I used to loop index 1:length(RT) (I also tried 1:216 but I get the same problem). I ran the whole script line by line and found when it gets to the bit of code below, the value for all_data_sess1 (or 2 or 3) get set to 1, and each time it goes through the for loop, 1 is added every time, hence the end result is all_data_sess1 = 216. How do I make it look at each row and not change/overwrite the matrix assigned to the variable?
for all_data_sess1 = 1:length(RT) %debugger shows running this line adds 1 to all_data_sess1 each time through the loop, rather than using it as a loop index.
if RT <= 2 %Disregarding RTs longer than 2 seconds Should this cutoff be sooner? RT <= 1.5?
if performance == 1 %Disregarding incorrect trials Is this the right way to organise 2 conditions?? if RT <= 2 && if performance == 1?
sortresultfunction %variables don't change, this isn't working...?
end
end
end
Thanks for any help!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!