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

4 ビュー (過去 30 日間)
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?

回答 (1 件)

Jan
Jan 2013 年 7 月 5 日
編集済み: Jan 2013 年 7 月 5 日
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.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by