inner2outer
table または timetable の table が table 内にある入れ子の階層の反転
説明
T2 = inner2outer(
で、T1
)T1
の変数が、自身が table または timetable であることがわかります。入れ子の tables または timetables を変数として含む table または timetable である T2
が返されます。T2
内の変数の名前は、T1
の入れ子の table または timetable 内の変数の名前から取られます。次に、inner2outer
は T2
の入れ子の table または timetable 内の変数を、図に示すように適切に再グループ化します。T1
に table または timetable でない変数がある場合、それらの変数は T2
で変更されません。
例
入れ子の table の反転
timetable T1
を読み込んで表示します。これは株の情報を含む入れ子の table をもっています。入れ子の table AAPL
および MSFT
は T1
の変数です。それぞれの入れ子の table は取り引き開始および終了の時点での株価、および出来高を、さまざまな会社についてもっています。
load nestedTables
T1
T1 = 3x2 timetable Dates AAPL MSFT Open Close Volume Open Close Volume ___________ __________________________ __________________________ 01-Jan-2017 64.539 71.704 107.17 66.429 91.77 78.7 01-Feb-2017 101.53 87.619 57.909 72.984 84.629 57.959 01-Mar-2017 60.381 76.464 72.067 78.127 76.492 82.883
Open
、Close
、および Volume
変数をそれ自身の入れ子の table でまとめてグループ化するには、関数 inner2outer
を使用します。
T2 = inner2outer(T1)
T2 = 3x3 timetable Dates Open Close Volume AAPL MSFT AAPL MSFT AAPL MSFT ___________ ________________ ________________ ________________ 01-Jan-2017 64.539 66.429 71.704 91.77 107.17 78.7 01-Feb-2017 101.53 72.984 87.619 84.629 57.909 57.959 01-Mar-2017 60.381 78.127 76.464 76.492 72.067 82.883
いくつかの計算は、T2
の入れ子の table でグループ化された各株のデータで計算したほうがより便利です。たとえば、T2.Volume
を使用してすべての株の正規化された出来高を計算できます。
T2
の Variables
プロパティを使用して、T2.Volume
を行列に変換します。それから、T2.Volume
の平均を T2.Volume
から減算し、結果を行列として返します。
normVolume = T2.Volume.Variables - mean(T2.Volume.Variables)
normVolume = 28.1213 5.5193 -21.1397 -15.2217 -6.9817 9.7023
入れ子の table で table 関数も使用できます。関数 varfun
を使用してすべての株の終値の平均を計算し、その平均を table に返します。
meanClose = varfun(@mean,T2.Close)
meanClose = 1x2 table mean_AAPL mean_MSFT _________ _________ 78.596 84.297
入力引数
T1
— 入力テーブル
table | timetable
入力 table。table または timetable として指定します。
拡張機能
tall 配列
メモリの許容量を超えるような多数の行を含む配列を計算します。
この関数は tall 配列を完全にサポートしています。詳細については、tall 配列を参照してください。
スレッドベースの環境
MATLAB® backgroundPool
を使用してバックグラウンドでコードを実行するか、Parallel Computing Toolbox™ のThreadPool
を使用してコードを高速化します。
この関数はスレッドベースの環境を完全にサポートしています。詳細については、Run MATLAB Functions in Thread-Based Environmentを参照してください。
バージョン履歴
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)