Borrar filtros
Borrar filtros

I generated 3 (1X1) random numbers using a=rand(1,1,3). When I gave [b n] =shiftdim(a), I got a b matrix of 3X1 matrix using the elements of variable a and got the n value as 2. Can u explain the concept behind this and how the value of “n” is det

1 visualización (últimos 30 días)
I generated 3 (1X1) random numbers using a=rand(1,1,3). When I gave [b n] =shiftdim(a), I got a b matrix of 3X1 matrix using the elements of variable a and got the n value as 2. Can u explain the concept behind this and how the value of “n” is determined?

Respuestas (1)

Jan
Jan el 5 de Jul. de 2013
Editada: Jan el 5 de Jul. de 2013
This is explained exhaustively in the documentation, so please read:
help shiftdim
doc shiftdim
Another good idea is to look into the source code:
edit shiftdim
You'll find out, that n replied by shiftdim is the number of dimensional shifts, which is required to bring the first non-signelton dimension (the first one which has not the length 1) to the front. In your case, 2 means, that the 3rd dimension is shifted twice to get the 1st one.

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by