table2stru​ct関数の挙動に疑問​があります.「構造体​→テーブル→構造体」​の順でデータを変換し​ても元に戻らないのは​おかしいのではないで​しょうか?

s = struct('a',{1,2},'b',{3,4})
st = struct2table(s)
sts = table2struct(st)
上のコードを実行した場合,構造体sは1x2 structですが,復元した構造体stsは2x1 structになります.
s(2)とsts(2)は同じ値を示しますが,sとstsでサイズが異なるというのは違和感があります.sts'のように転置をすれば解決しますが,table2struct関数の出力サイズを1xNにするべきではないでしょうか?

1 commentaire

1xNの行ベクトルにすると元に戻ります。しかしこれは求めている table の形でしょうか?
s = struct('a',[1,2,3,4],'b',[5,6,7]);
st = struct2table(s)
st = 1×2 table
a b ________________ ___________ 1 2 3 4 5 6 7
sts = table2struct(st)
sts = struct with fields:
a: [1 2 3 4] b: [5 6 7]

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!