MATLAB Answers

acess struct data without typing file name

5 views (last 30 days)
Carolina Brum Medeiros
Carolina Brum Medeiros on 14 Apr 2012
you answered my question offering as option U=load(); but unfortunately this doesn't solve my problem.
by using uigetfile I can select the .mat file that contains my structured data. this is good. I have multiple files named, i.e. bending0001, bending0002, bending0003 and so on
to access the data, I'm doing this, for example:
Analog_SG_full = bending0001.Analog.Data(1,:);
as I have multiple files and multiple fields from which I want to extract data, I don't want to type the name bending000X for each access.

Answers (1)

Walter Roberson
Walter Roberson on 14 Apr 2012
for K = 1 : 3
fileName = sprintf('bending%04d.mat', K);
U = load(fileName);
fprintf('\nData for file %d\n', K);
Carolina Brum Medeiros
Carolina Brum Medeiros on 20 Apr 2012
Dear Walter, this really works good!!!
thank you so much!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by