Main Content

unshiftdata

構文

y = unshiftdata(x,perm,nshifts)

説明

y = unshiftdata(x,perm,nshifts)shiftdata でシフトされたデータの方向を元に戻します。置換ベクトルは perm で与えられ、nshiftsshiftdata から返されたシフト数です。

unshiftdatashiftdata とともに使用します。これらの関数は、filtergoertzelsgolayfiltsosfilt のように、特定の次元を操作する関数を作成する場合に役立ちます。

すべて折りたたむ

  1. 3-by-3 魔方陣を作成します。

    x = fi(magic(3))
    x = 
    
         8     1     6
         3     5     7
         4     9     2
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Signed
                WordLength: 16
            FractionLength: 11
  2. 行列 x をシフトし、2 次元方向に操作します。

    [x,perm,nshifts] = shiftdata(x,2)
    x = 
    
         8     3     4
         1     5     9
         6     7     2
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Signed
                WordLength: 16
            FractionLength: 11
    
    perm =
    
         2     1
    
    
    nshifts =
    
         []

    このコマンドで、置換ベクトル perm とシフト数 nshifts がシフトされた行列 x とともに返されます。

  3. この行列を元の形状に戻します。

    y = unshiftdata(x,perm,nshifts)
    y = 
    
         8     1     6
         3     5     7
         4     9     2
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Signed
                WordLength: 16
            FractionLength: 11
  1. x を行ベクトルとして定義します。

    x = 1:5
    x =
    
         1     2     3     4     5
  2. dim を空に定義し、x の大きさが 1 でない最初の次元を 1 列目にシフトします。

    [x,perm,nshifts] = shiftdata(x,[])
    x =
    
         1
         2
         3
         4
         5
    
    
    perm =
    
         []
    
    
    nshifts =
    
         1

    このコマンドで、x が列ベクトルとして返され、置換ベクトル perm とシフト数 nshifts も返されます。

  3. unshiftdata を使用して、x を元の形状に戻します。

    y = unshiftdata(x,perm,nshifts)
    y =
    
         1     2     3     4     5

バージョン履歴

R2008a で導入

参考