Can anybody help me with what this kind of thing means In MatLab

1 view (last 30 days)
I am studying some tagging with Blue crabs and I need to make sure I am on the right track with interpreting the data. Would anyone be able to tell me in simpler terms what the data below is trying to find?
idx_r1_A1 = find ( ant_num_r1 == 1 );
idx_r1_A2 = find ( ant_num_r1 == 2 );
idx_r2_A1 = find ( ant_num_r2 == 1 );
idx_r2_A2 = find ( ant_num_r2 == 2 );
idx_r3_A1 = find ( ant_num_r3 == 1 );
idx_r3_A2 = find ( ant_num_r3 == 2 );
idx_r4_A1 = find ( ant_num_r4 == 1 );
idx_r4_A2 = find ( ant_num_r4 == 2 );

Answers (2)

Walter Roberson
Walter Roberson on 25 Mar 2013
find() returns the index locations at which the condition was true. So the first find() is returning the indices in ant_num_r1 that were equal to 1.

Matt Kindig
Matt Kindig on 25 Mar 2013
Each of the idx_rX... variables are the output of find, and are indicating the indices of where the expression inside the parentheses is true. To be clear:
- The expression
ant_num_r1 == 1
creates a logical matrix, the same size as ant_num_r1, where 1 (true) occurs everytime ant_num_r1 is equal to 1, and is 0 (false) otherwise.
- The find() function determines the index positions in ant_num_r1 where that expression is true (i.e. ant_num_r1 is equal to 1).
The ant_num_r1==2 is doing the same for when ant_num_r1 is equal to 2, and vice versa. Does this answer your question?

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!