Problem using find function in Matlab

Posted by Peter Etchells on Stack Overflow See other posts from Stack Overflow or by Peter Etchells
Published on 2010-04-19T18:47:57Z Indexed on 2010/04/19 19:13 UTC
Read the original article Hit count: 166

Filed under:
|

Hi all, 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.

What I'm trying to do is something like...

    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

...in order to find the relevant row in predicted_data where the look up latency corresponds to the actual latency. I then use this to created an amalgamated data set, full_set.

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 know is in predicted_data(:,1) (as I've double-checked during debugging).

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.

Furthermore, during debugging mode, if I use find to try and find a hard-coded value of actual_latency, it doesn't always work. Sometimes yes, sometimes no.

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.

© Stack Overflow or respective owner

Related posts about matlab

Related posts about find