Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem using the find function in MATLAB
    primarykey
    data
    text
    <p>I have two arrays of data that I'm trying to amalgamate. One contains actual latencies from an experiment in the first column (e.g. 0.345, 0.455... never more than 3 decimal places), along with other data from that experiment. The other contains what is effectively a 'look up' list of latencies ranging from 0.001 to 0.500 in 0.001 increments, along with other pieces of data. Both data sets are X-by-Y doubles.</p> <p>What I'm trying to do is something like...</p> <pre><code>for i = 1:length(actual_latency) row = find(predicted_data(:,1) == actual_latency(i)) full_set(i,1:4) = [actual_latency(i) other_info(i) predicted_info(row,2) ... predicted_info(row,3)]; end </code></pre> <p>...in order to find the relevant row in <code>predicted_data</code> where the look up latency corresponds to the actual latency. I then use this to created an amalgamated data set, <code>full_set</code>.</p> <p>I figured this would be really simple, but the find function keeps failing by throwing up an empty matrix when looking for an actual latency that I <em>know</em> is in <code>predicted_data(:,1)</code> (as I've double-checked during debugging). </p> <p>Moreover, if I replace find with a for loop to do the same job, I get a similar error. It doesn't appear to be systematic - using different participant data sets throws it up in different places. </p> <p>Furthermore, during debugging mode, if I use find to try and find a hard-coded value of <code>actual_latency</code>, it doesn't always work. Sometimes yes, sometimes no.</p> <p>I'm really scratching my head over this, so if anyone has any ideas about what might be going on, I'd be really grateful.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload