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

조회 수: 6 (최근 30일)
masahiro yasuda
masahiro yasuda 2022년 12월 5일
댓글: Atsushi Ueno 2022년 12월 5일
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
Atsushi Ueno
Atsushi Ueno 2022년 12월 5일
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]

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 データ型の変換에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!