Azzera filtri
Azzera filtri

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 visualizzazione (ultimi 30 giorni)
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?

Risposte (1)

Jan
Jan il 5 Lug 2013
Modificato: Jan il 5 Lug 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.

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by