Append corresponding values to new matrix

4 views (last 30 days)
MadjeKoe
MadjeKoe on 15 Jun 2022
Answered: AMIT POTE on 3 Jul 2022
Hi guys, I am trying to append accuracy values of the rows that match the statement into a list. In my r matrix there are 28 participants each performing 5 blocks of 120 trials. Per trial (600 in total), I want to store every accuracy value. So for example, when block == 1 and trials == 1, I want to append all 56 corresponding accuracy scores. Is there anyone who can help me out?
r(:,14) = accuracy;
sd = zeros(5,120);
for b = 1:5
for s = 1:120
if r(:,3) == b & r(:,4) == s
sd = accuracy(s,1)
end
end
end

Answers (1)

AMIT POTE
AMIT POTE on 3 Jul 2022
You can append new values to a newly created array using end operator. For ex:
If suppose your accuracy array is accuracy_arr, then you can write the following code to append values:
accuracy_arr = {}
accuracy_arr = [accuracy_arr new_val]
To know more about this you can go through the documentation:

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!