How to concatenate selected data of two .mat files

조회 수: 3 (최근 30일)
Hugo
Hugo 2022년 1월 20일
답변: Image Analyst 2022년 1월 20일
Hi,
I have two .mat files, named A.mat and B.mat. Those files have 1000 lines and 10 columns. they are both in format "Table".
I would like to create a new table, name C.mat, which is the file A.mat but has the last column of file B.mat added as an additional column.
Size(A.mat)=1000*10
Size(B.mat)=1000*10
Size(C.mat)=1000*11
The column 11 of the file C.mat is the column 10 of the file B.mat. The rest of the file C.mat is equal to the file A.mat
The file C.mat must be in the format double, as I have float numbers in all cells. Table2cell will do?
I thank you all in advance,
Best regards,

채택된 답변

KSSV
KSSV 2022년 1월 20일
Let A, B be your tables.
C = A ;
C.last = B.(10) ; % instead of last you give your required name
  댓글 수: 2
Hugo
Hugo 2022년 1월 20일
Hi,
Thank you for your swift reply. How can I use your code if I would like to use .mat files for my tables A,B and C?
Best regards,
KSSV
KSSV 2022년 1월 20일
You said the mat files have tables. Load the mat files and instead of A and B use the respective file's table array variable.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2022년 1월 20일
If t1 and t2 are your tables, how about just tacking on the right column?
t3 = [t1, t2(:, end)]
t1 and t2 both need to have the same number of rows. If not, look into the join() function.

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by