Please how can I store all my matrix?

조회 수: 14 (최근 30일)
Inouss
Inouss 2019년 6월 13일
댓글: Inouss 2019년 6월 13일
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

채택된 답변

James Tursa
James Tursa 2019년 6월 13일
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
James Tursa
James Tursa 2019년 6월 13일
편집: James Tursa 2019년 6월 13일
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.
Inouss
Inouss 2019년 6월 13일
Thank you James it works but I would like to access these matrices and be able to draw a plot with all the data.
ps: the matrices contain 2 columns and thousands of lines

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by