フィルターのクリア

why readtable create field "D" in the struct "D1"

1 回表示 (過去 30 日間)
Luca Re
Luca Re 2023 年 6 月 16 日
編集済み: Walter Roberson 2023 年 6 月 17 日
function D1=TEST()
D=readtable('test.txt','delimiter',',');
save canc.tset D
D1=load('canc.tset',"-mat")
end
i access it using
D1.D...
it's possibile to avoid "D" field?
  1 件のコメント
Stephen23
Stephen23 2023 年 6 月 16 日
編集済み: Stephen23 2023 年 6 月 16 日
"why readtable create field "D" in the struct "D1""
It doesn't. READTABLE has nothing to do with the scalar structure returned by LOAD.

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2023 年 6 月 16 日
編集済み: Stephen23 2023 年 6 月 16 日
If there is only one variable in the MAT file (regardless of its extension) and you do not know/care what its name is:
C = struct2cell(load(..));
assert(isscalar(C),'Only one array can be LOADed')
T = C{1}
If the variable name is known in advance, e.g. "D"
S = load(..)
T = S.D
  12 件のコメント
Stephen23
Stephen23 2023 年 6 月 17 日
save('prova.txt','T')
SAVE is an exception: it requires the name/s of the variable/s that you want to save, not the variables themselves. That is explained and shown in the SAVE documentation. You should look at the documentation of every function that you use.
Luca Re
Luca Re 2023 年 6 月 17 日
thank you.. I appreciate the effort you took in answering me

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by