Join matrices in for loop
1 次查看(过去 30 天)
显示 更早的评论
I am importing several files in matlab which are in csv format. Each of these files has two columns. So when I import the first one I create a matrix with two columns. therefore I would like to join this 2 column matrices in one matrix. I would like to do that in a for loop.
My code is the following:
files=dir('*.csv');
Data=[];
for i=1:length(files)
fid(i)=fopen(files(i).name);
files(i).values=textscan(fid(i), '%f %f','delimiter',',','HeaderLines',20,'MultipleDelimsAsOne',1);
A=cell2mat(files(i).values);
end
In my code each time the matrix A is a two column matrix. So I would like to join all the A matrices.
0 个评论
采纳的回答
Azzi Abdelmalek
2013-4-19
files=dir('*.csv');
A=[];
for i=1:length(files)
fid(i)=fopen(files(i).name);
files(i).values=textscan(fid(i), '%f %f','delimiter',',','HeaderLines',20,'MultipleDelimsAsOne',1);
A=[A;cell2mat(files(i).values)];
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!