combining/concatenation mat files

조회 수: 3 (최근 30일)
cr28
cr28 2012년 9월 6일
답변: DIPAK KUMAR CHAUBEY 2018년 5월 31일
Hi,
i have 4 mat files in the array format(these files are outputs from a simulink model). the variables are the same in all 4 files. time is one of them.
the time sequence in all the 4 files is different (file A is from 1-250 sec, file B is from 251-500 sec.....file D from 750-1000 sec)
I want to merge these files so as to form a new file with time from 1-1000 sec
Any idea how to do it???
[i looked at other solutions on this forum & it didn't work. in my case although i have 250x3 array (time voltage and current), the variable is defined as 'sample1' i.e one variable name for 3 values]

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 6일
편집: Azzi Abdelmalek 2012년 9월 6일
new_var=[];
load file1
new_var=[new_var;var]
load file2
new_var=[new_var;var]
load file3
new_var=[new_var;var]
load file4
new_var=[new_var;var]
save new_file nw_var
% var is the name of your array

추가 답변 (4개)

cr28
cr28 2012년 9월 6일
thanx Azzi but this gives me a file with data written side by side i.e i get a file with 12 column...how do i merge them one below the other???
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 6일
편집: Azzi Abdelmalek 2012년 9월 6일
there is no 16 colums, it still 3 because I'am using a vertical concatenation. check the variable new_var
cr28
cr28 2012년 9월 6일
Azzi, i just tried this and it worked........
X=[fileA,fileB];

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


Will Johnson
Will Johnson 2017년 5월 20일
편집: Will Johnson 2017년 5월 20일
Nota: En este caso la variable en los archivos es: VarA
1- Asignamos nuestros ".mat" a una variable
c1=load('file_1.mat')
c2=load('file_2.mat')
c3=load('file_3.mat')
2- Para concatenar se hace de la siguiente manera:
ctotal=[c1.VarA ; c2.VarA ; c3.VarA]

DIPAK KUMAR CHAUBEY
DIPAK KUMAR CHAUBEY 2018년 5월 31일
how to merge two mat files having 35 x 4 cell and 35 x 701 double into one mat file??

DIPAK KUMAR CHAUBEY
DIPAK KUMAR CHAUBEY 2018년 5월 31일
how to merge two mat files having 35 x 4 cell and 35 x 701 double into one mat file??

카테고리

Help CenterFile Exchange에서 Filename Construction에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by