How to convert CartesianIndex to integer

Hi,

I am using findall function to create an array. but the results are in CartesianIndex as shown below.

A = findall(x->x>0, test)

This results in
5-element Array{CartesianIndex{2},1}:
CartesianIndex(1, 3)
CartesianIndex(1, 4)
CartesianIndex(1, 5)
CartesianIndex(1, 6)
CartesianIndex(1, 8)

How can I convert CartesianIndex to integer printing only the 2nd output like:
3,4,5,6,8

Thank you.

[I[2] for I in A]. But maybe the problem is that test is a matrix when you really want it to be a vector? Try findall(x->x>0, vec(test)).

2 Likes

Using vec solved the problem.

Thank you.