|
Diego Zegarra wrote:
> Could you please explain me though what the second 2 in the code does?
>> max(A(isfinite(A(:,2)),2);
Note: I missed a ')' before the ';', it should be
max(A(isfinite(A(:,2)),2))
To understand it, rewrite it as a sequence of steps:
T1 = isfinite(A(:,2));
T2 = A(T1,2);
max(T2)
This makes it clear that both 2's are selecting column 2 of
the matrix A.
The trick involved is that you have to understand "logical indexing",
which you can find more information about in the matlab documentation,
most directly if you search on the phrase
logical types
|