Sohom Mandal
Sohom Mandal

Reputation: 23

Combining two .mat file into one

I want to combine two .mat files into one in Matlab. One file contents 1x776 cells and 1x1 struct another one contents 1x277 cells and 1x1 struct. I want to bind this two files in one and keep the information in it.

enter image description here

Upvotes: 0

Views: 2686

Answers (1)

IKavanagh
IKavanagh

Reputation: 6187

Simply clear the MATLAB workspace. Load both of your .mat files and then save the MATLAB workspace to a new file.

>> clear all
>> load('1.mat');
>> load('2.mat');
>> save('combined.mat');

Alternatively you could load the two .mat files and explicitly pass the variables you want to save into save doing away with the need for clear all

>> load('1.mat');
>> load('2.mat');
>> save('combined.mat', 'cells1', 'struct1', 'cells2', 'struct2');

Upvotes: 1

Related Questions