How to Compile arrays from many txt file into one array in MATLAB
I have observations txt file, number of files equals day in year. Column 1 and 2 in txt files are time and obsearved results, some of them miss.
I want to combile 2nd c开发者_JAVA技巧olumn of each file within one big array.
I tried to create X Cell as big array. its size as (desired column, desired row) and tried fill cell with a = X(:,1) but it's not solve.
How do I do this?
Presumably, the problem is that each file has a different number of elements.
Assuming the data from each file are in a cell array A
, then you can form a new array as follows:
n = numel(A);
m = cellfun(@(x) size(x,1), A);
B = NaN(max(m), n);
for i = 1:n
B(1:m(i),i) = A{i}(:,2);
end
However, this doesn't align the times of the observations between the files. Comment if you need to do that too.
精彩评论