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

Illustration
Luca Re - 2023-06-19T12:19:22+00:00
Question: why readtable create field "D" in the struct "D1"?

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?    

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

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

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!