Merge matrices into one matrix based on column order

1 次查看(过去 30 天)
Hy All, I'm new Matlab user i need to merge/interlace/combine a number of matrix in one , i have fond on network
A1 =[1 2;
3 4]
A2 =[5 6;
7 8]
MA = reshape([A1;A2],size(A1,1),[])
MA =
1 5 2 6
3 7 4 8
Can any on help me to generalised it fo n Matrix of course with the same dimension (rows and columns), i need to generalise it for n number (a loop , for i :1 to n), best regards
  4 个评论
Stephen23
Stephen23 2016-3-28
编辑:Stephen23 2016-3-28
"reading these files allows the matrices creation" How? What code are you using to import them into MATLAB?

请先登录,再进行评论。

采纳的回答

Stephen23
Stephen23 2016-3-28
编辑:Stephen23 2016-3-28
You don't tell us anything about how you are reading these file into MATLAB, so here is a general overview of how to solve your original question:
% read the file data into a cell array:
N = {list of filenames};
C = cell(1,numel(N));
for k = 1:numel(N)
C{k} = csvread(N{k});
end
% concatenate data and rearrange:
M = vertcat(C{:});
out = reshape(M,2,[])
You also did not define exactly what you mean by "interlace", but once you have all of the data in one matrix M it is easy to experiment with reshape.
  1 个评论
judy abbott
judy abbott 2016-3-28
These numbered variables are obtained from instrumental measurements (thermometer and pressure gauge) as Output-files (txt format without heading), reading these files allows the matrices creation (Temperature in first column and Pressure in second one) (Time in rows) and the file name indicates the instrument name.
For the matrix A1
# Temperature # Pressure #
Time # 1 # 2 #
Time # 3 # 4 #
The variables arranged to an statistically and plotting futures processus

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by