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

Luca Re · Jun 19, 2023 · 2.1K views
Question
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 PhD Expert
Answered Aug 14, 2026

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

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!