q(:,:,3) what does mean in matrix

14 visualizaciones (últimos 30 días)
tina jain
tina jain el 2 de Mzo. de 2015
Editada: Stephen23 el 5 de Mzo. de 2015
q(:,:,3) all rows and all colomns, but 3 stands for what

Respuestas (3)

Stephen23
Stephen23 el 2 de Mzo. de 2015
Editada: Stephen23 el 5 de Mzo. de 2015
The MATLAB documentation that introduces multidimensional arrays names the third dimension as "page", just as the first and second are named "row" and "column" respectively. Quoting from that linked page (take a look!):
The first references array dimension 1, the row.
The second references dimension 2, the column.
The third references dimension 3. This illustration uses the concept of a page to represent dimensions 3 and higher
Note that there can be more than three dimensions! Also note that in mathematics a matrix refers exclusively to a 2D array, if it has more than 2D then it is an array. This means actually q from the original question is not a matrix, as it has at least three pages: q(:,:,3).
EDIT: If you are working with images, then note that an RGB image stores each of the R, G, and B colors on separate pages, in this order:
data = imread(filename);
data(:,:,1) % red
data(:,:,2) % green
data(:,:,3) % blue

Adam
Adam el 2 de Mzo. de 2015
Take only the 3rd element for each row and column in the 3rd dimension of the matrix rather than all elements.

Star Strider
Star Strider el 2 de Mzo. de 2015
The 3 stands for the third element in the third dimension of the (NxMx3) matrix ‘q’.
To illustrate, run this code snippet:
q = randi(10, 2, 2, 4)
x = q(:,:,3)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by