Problem with combining .mat files

1 回表示 (過去 30 日間)
adele alias
adele alias 2019 年 6 月 20 日
コメント済み: Adam Danz 2019 年 6 月 21 日
Hi, I want to combine two .mat files that have the same matrice variables. The problem is when I combine them they are combined horizontally and I wish for them to be combined vertically.
Ex :
A (file1)=`
(222
111
333)
A(file2)=
(111
222
333)
Combined =
(222 111
111 222
333 333)
  3 件のコメント
adele alias
adele alias 2019 年 6 月 21 日
datacell1 = load('file1.mat');
datacell2 = load('file2.mat');
combined2.uu = [datacell1.uu, datacell2.uu];
combined2.vv = [datacell1.vv, datacell2.vv];
combined2.x1 = [datacell1.x1, datacell2.x1];
combined2.y1 = [datacell1.y1, datacell2.y1];
save('Combinedfile.mat', '-struct', 'combined2')
It combines the matrices horizontally and not vertically like I wish it would.
Adam Danz
Adam Danz 2019 年 6 月 21 日
To concatenate vertically,
datacell1 = load('file1.mat');
datacell2 = load('file2.mat');
combined2.uu = [datacell1.uu; datacell2.uu];
combined2.vv = [datacell1.vv; datacell2.v
% ^ semicolon

サインインしてコメントする。

回答 (1 件)

Himanshu Tripathi
Himanshu Tripathi 2019 年 6 月 21 日
  1 件のコメント
adele alias
adele alias 2019 年 6 月 21 日
Thankyou ! I used the function vertcat and it worked.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBig Data Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by