couple a value in a column of a cell array to a value in another column of the cell array

1 view (last 30 days)
I have a variable, which is response_time_rh, which is a 24x1 cell variable, containing the response times.
What I want to do is, that I want to know which of these response times are <100.
Therefore I did the following:
thresshold = 100;
r_t_rh_k100 = cellfun(@(x) x,100, response_time_rh);
This creates a logicical with ones and zeros, indicating which one is smaller than 100
Then I want to know the response time which was smaller than 100, therefore I did the following:
response_time_rh_k100 = response_time_rh(r_t_rh_k100);
This gave me the value of the cell with a reaction time <100
In addition, I have a variable called t and this t variable is a 72x40 cell. In column 24 there are other values and I need the value in column 24 that corresponds with the value of the cell with a reaction time <100 (are on the same row), so with the response_time_rh_k100. I don''t know how to do this.
I did this:
time_outc_reward_hit_k100 = t(r_t_rh_k100, 24)
However, this did not what I want, for example if the logical was
1
0
0
0
It always selects the value in colum 24 for the first one, while I have different conditions: reward_hit and reward_toolate, which are mixed, so therefore it does not select the correct value... does this make any sense? I do not know how to select the correct one.
Can anyone help me?

Answers (1)

BhaTTa
BhaTTa on 10 Jun 2025
Hey @Joyce Dieleman, I assume that the issue you're facing is due to an alignment problem between your response_time_rh data (24x1) and your full t array (72x40). Your logical index r_t_rh_k100 is based on the 24 rows, but you're trying to apply it directly to the 72 rows, causing a mismatch.
To correctly select the corresponding t values, you need to know which rows in the original t array your response_time_rh values came from. Let's assume you have a logical array, say is_reward_hit_trial (72x1), that indicates which rows in t correspond to your response_time_rh data.

Categories

Find more on Operators and Elementary Operations 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!