struct2cell
構造体を cell 配列に変換
説明
例
構造体を作成します。
S.x = linspace(0,2*pi);
S.y = sin(S.x);
S.title = 'y = sin(x)'
S = struct with fields:
x: [0 0.0635 0.1269 0.1904 0.2539 0.3173 0.3808 0.4443 0.5077 0.5712 0.6347 0.6981 0.7616 0.8251 0.8885 0.9520 1.0155 1.0789 1.1424 1.2059 1.2693 1.3328 1.3963 1.4597 1.5232 1.5867 1.6501 1.7136 1.7771 1.8405 1.9040 1.9675 … ] (1×100 double)
y: [0 0.0634 0.1266 0.1893 0.2511 0.3120 0.3717 0.4298 0.4862 0.5406 0.5929 0.6428 0.6901 0.7346 0.7761 0.8146 0.8497 0.8815 0.9096 0.9341 0.9549 0.9718 0.9848 0.9938 0.9989 0.9999 0.9969 0.9898 0.9788 0.9638 0.9450 0.9224 … ] (1×100 double)
title: 'y = sin(x)'
S
を cell 配列に変換します。
C = struct2cell(S)
C=3×1 cell array
{[ 0 0.0635 0.1269 0.1904 0.2539 0.3173 0.3808 0.4443 0.5077 0.5712 0.6347 0.6981 0.7616 0.8251 0.8885 0.9520 1.0155 1.0789 1.1424 1.2059 1.2693 1.3328 1.3963 1.4597 1.5232 1.5867 1.6501 1.7136 1.7771 1.8405 1.9040 1.9675 2.0309 2.0944 2.1579 2.2213 2.2848 2.3483 2.4117 2.4752 2.5387 2.6021 2.6656 2.7291 2.7925 2.8560 2.9195 2.9829 3.0464 3.1099 3.1733 3.2368 3.3003 3.3637 3.4272 3.4907 3.5541 3.6176 3.6811 3.7445 3.8080 3.8715 3.9349 3.9984 4.0619 4.1253 4.1888 4.2523 4.3157 4.3792 4.4427 4.5061 4.5696 4.6331 4.6965 4.7600 4.8235 4.8869 4.9504 5.0139 5.0773 5.1408 5.2043 5.2677 5.3312 5.3947 5.4581 5.5216 5.5851 5.6485 5.7120 5.7755 5.8389 5.9024 5.9659 6.0293 6.0928 6.1563 6.2197 6.2832]}
{[0 0.0634 0.1266 0.1893 0.2511 0.3120 0.3717 0.4298 0.4862 0.5406 0.5929 0.6428 0.6901 0.7346 0.7761 0.8146 0.8497 0.8815 0.9096 0.9341 0.9549 0.9718 0.9848 0.9938 0.9989 0.9999 0.9969 0.9898 0.9788 0.9638 0.9450 0.9224 0.8960 0.8660 0.8326 0.7958 0.7557 0.7127 0.6668 0.6182 0.5671 0.5137 0.4582 0.4009 0.3420 0.2817 0.2203 0.1580 0.0951 0.0317 -0.0317 -0.0951 -0.1580 -0.2203 -0.2817 -0.3420 -0.4009 -0.4582 -0.5137 -0.5671 -0.6182 -0.6668 -0.7127 -0.7557 -0.7958 -0.8326 -0.8660 -0.8960 -0.9224 -0.9450 -0.9638 -0.9788 -0.9898 -0.9969 -0.9999 -0.9989 -0.9938 -0.9848 -0.9718 -0.9549 -0.9341 -0.9096 -0.8815 -0.8497 -0.8146 -0.7761 -0.7346 -0.6901 -0.6428 -0.5929 -0.5406 -0.4862 -0.4298 -0.3717 -0.3120 -0.2511 -0.1893 -0.1266 -0.0634 -2.4493e-16]}
{'y = sin(x)' }
cell 配列にはフィールド名は含まれません。cell 配列でフィールド名を返すには、関数 fieldnames
を使用します。fieldnames
と struct2cell
はフィールド名と値を同じ順序で返します。
fields = fieldnames(S)
fields = 3×1 cell
{'x' }
{'y' }
{'title'}
入力引数
入力構造体配列。S
は任意のサイズの構造体配列にすることができます。S
が、p
個のフィールドをもつ m
行 n
列の構造体配列の場合、C
は p
x m
x n
の cell 配列になります。
拡張機能
使用上の注意および制限:
S
が構造体の可変サイズの配列である場合、すべての要素の各フィールドのタイプは同じでなければなりません。異種混合 cell 配列を可変サイズにすることはできません。構造体
S
の固定サイズの配列で、struct2cell
がS
を同種の cell 配列に変換できない場合、出力 cell 配列は異種混合になります。異種混合の出力 cell 配列は、最大 1024 の要素をもつことができます。
この関数はスレッドベースの環境を完全にサポートしています。詳細については、スレッドベースの環境での MATLAB 関数の実行を参照してください。
この関数は分散配列を完全にサポートしています。詳細については、分散配列を使用した MATLAB 関数の実行 (Parallel Computing Toolbox)を参照してください。
バージョン履歴
R2006a より前に導入
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)