opening structure in a loop

2 Ansichten (letzte 30 Tage)
Rica
Rica am 11 Nov. 2014
Beantwortet: Julia am 11 Nov. 2014
hi all, i have this type of data:
% data_1.mat data_2.mat......data_50.mat.
they are structure and contains: as exemple data_1.A =[10x500] data_1.B=[50X500] .
i want to process the data_1....data_50in a loop:
for k=1:50
load (['data_' num2str(k) '.mat'])
*++ +++how could i generate data_(k).A dynamically???++++++++++++++++*
end
thank youall

Akzeptierte Antwort

Julia
Julia am 11 Nov. 2014
Hi,
perhaps this helps; it's from the Matlab help:
filename = 'durer.mat';
myVars = {'X','caption'};
S = load(filename,myVars{:})
S =
X: [648x509 double]
caption: [2x28 char]
And then you can access X with
S.X

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by