why readtable create field "D" in the struct "D1"
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Luca Re
am 16 Jun. 2023
Bearbeitet: Walter Roberson
am 17 Jun. 2023
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1413029/image.png)
1 Kommentar
Akzeptierte Antwort
Stephen23
am 16 Jun. 2023
Bearbeitet: Stephen23
am 16 Jun. 2023
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 Kommentare
Stephen23
am 17 Jun. 2023
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!