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

1 次查看(过去 30 天)
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 );

回答(2 个)

Walter Roberson
Walter Roberson 2013-3-25
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 2013-3-25
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?

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by