Reputation: 117
I want to do the following in Matlab:
[nnz_rows, nnz_cols] = find(messages_matrix);
nnz_matrix_points = [nnz_rows, nnz_cols];
I want nnz_matrix_points
to be a 2xn
vector containing the index that find returns, but I want to do it on one line. I tried to search online, with no success.
Upvotes: 0
Views: 31
Reputation: 6187
[nnz_matrix_points(1, :) nnz_matrix_points(2, :)] = find(messages_matrix);
produces a 2xN
matrix.
[nnz_matrix_points(:, 1) nnz_matrix_points(:, 2)] = find(messages_matrix);
produces a Nx2
matrix.
Upvotes: 2