Azzera filtri
Azzera filtri

Merge matrices into one matrix based on column order

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Stephen23
Stephen23 il 28 Mar 2016
Modificato: Stephen23 il 28 Mar 2016
"reading these files allows the matrices creation" How? What code are you using to import them into MATLAB?
judy abbott
judy abbott il 28 Mar 2016
I import them by:
[M,delimiterOut]=importdata('file1.txt')

Accedi per commentare.

Risposta accettata

Stephen23
Stephen23 il 28 Mar 2016
Modificato: Stephen23 il 28 Mar 2016
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 Commento
judy abbott
judy abbott il 28 Mar 2016
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

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by