Please how can I store all my matrix?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Inouss
am 13 Jun. 2019
Kommentiert: Inouss
am 13 Jun. 2019
Hello,
I made a for loop that imports a database (several matrix), I wanted to store all matrices on a single matrix but I can store only the last one. Please how can I store all the matrix?
for i = 1:length(find([d.isdir]==0))-1
channel = "/channel_"+i+".dat";
location = strcat(location_filename,channel);
location= sprintf('% s', location);
%import Matrix
channel = [importdata(location)];
end
y = channel
0 Kommentare
Akzeptierte Antwort
James Tursa
am 13 Jun. 2019
Maybe use a cell array:
channel{i} = [importdata(location)];
Then at the end you can work with the individual matrices as channel{i}, or concatenate all of the channel elements into a single larger matrix.
3 Kommentare
James Tursa
am 13 Jun. 2019
Bearbeitet: James Tursa
am 13 Jun. 2019
Sorry, I forgot you had previously used that variable name. Simply pick another name. E.g.,
channels{i} = [importdata(location)];
You might want to pre-allocate channels prior to the loop.
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!