필터 지우기
필터 지우기

Merge matrices into one matrix based on column order

조회 수: 1 (최근 30일)
judy abbott
judy abbott 2016년 3월 28일
댓글: judy abbott 2016년 3월 28일
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?
judy abbott
judy abbott 2016년 3월 28일
I import them by:
[M,delimiterOut]=importdata('file1.txt')

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

채택된 답변

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