How to write a for statement for multiple .mat files?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Paul Scotti
am 21 Nov. 2015
Beantwortet: Star Strider
am 21 Nov. 2015
I have 6 .mat files each with different file names. I am able to import them into the workspace but I am having difficulty figuring out how I am supposed to run analyses on particular columns or rows for each .mat file in succession.
For instance, with something like this, I don't know what I'm supposed to do in order to have TrialNum equal all the values of the first column for each .mat file.
for i=1:6
TrialNum = %all the values for the 1st column of each .mat file
end
I apologize for the basic question, I'd really appreciate any help!
0 Kommentare
Akzeptierte Antwort
Star Strider
am 21 Nov. 2015
I’m not certain how you’re importing them (using load obviously), but with or without an output argument. If you load them with an output argument in a loop with index ‘k’, e.g.:
D{k} = load('Data1.mat');
they will load as a structure in ‘D’. You can load only specific variables as well. (See the documentation for load for those details.) You can then dissect out the variables of interest from the structure for each file, and define the appropriate columns.
I have only the information you supplied, so I can’t be more specific.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!