I am given a matrix:

x = zeros(6,7)

which can have one random nonzero value in the sixth row and I need to be able to detect which column has this nonzero value.

I have tried to use

[row,col] = find(x)

but this does not create a "col" variable that I am able to use in an "if" statement in the function I am writing. Is there a way to find which column has this nonzero value and set the number of the column as a variable. Any help is appreciated.

## Best Answer