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!
댓글 수: 1
참고 항목
카테고리
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!