Top "Matrix-indexing" questions

Indexing into a matrix is a means of selecting a subset of elements from the matrix/array

How can I find the maximum value and its index in array in MATLAB?

Suppose I have an array, a = [2 5 4 7]. What is the function returning the maximum value and its index? For example, in …

matlab max matrix-indexing
How can I efficiently remove zeroes from a (non-sparse) matrix?

I have a matrix: x = [0 0 0 1 1 0 5 0 7 0]; I need to remove all of the zeroes, like so: x = [1 1 5 7]; The matrices I am …

arrays matlab performance matrix matrix-indexing
How to select a submatrix (not in any particular pattern) in Matlab

How to select a submatrix (not in any pattern) in Matlab? For example, for a matrix of size 10 by 10, how …

matlab matrix matrix-indexing
What does [:, :] mean on NumPy arrays

Sorry for the stupid question. I'm programming on PHP but found some nice code on Python and want to "recreate" …

python arrays numpy matrix-indexing
Can I slice tensors with logical indexing or lists of indices?

I'm trying to slice a PyTorch tensor using a logical index on the columns. I want the columns that correspond …

python matrix-indexing pytorch
In R, what does a negative index do?

I am porting part of a program (not enough to compile and run) from R to C++. I am not …

r syntax indexing matrix-indexing
Interpretation of negative index when subsetting a data.frame

I am very new to R and at times get stuck with the codes. I came across one of this …

r indexing dataframe matrix-indexing
How to extract elements from a matrix using a vector of indices?

Suppose I have a matrix A of order m×n and a vector of order m×1. I would like to …

python numpy matrix vector matrix-indexing
List comprehension and logical indexing

Slowly transitioning from Matlab to Python... I have this list of the form list1 = [[1, 2, nan], [3, 7, 8], [1, 1, 1], [10, -1, nan]] and another list …

python list matrix-indexing
MATLAB: Select all of an array EXCEPT in given ranges

I'd like to perform metrics on the contents of an array that do NOT fall within certain ranges. For example, …

arrays matlab matrix matrix-indexing