Search code examples
matlabmergemat-file

How to merge two .mat files that contain the same variables


I have two .mat files Argiris1.mat and Argiris2.mat that both contain the same variables ,how can i load them both on workspace and for example if one of the variables is Wkinet which is 100000*1000 matrix for every file and create an 200000*1000 matrix by combining the two


Solution

  • You can load the content of each MAT-Files into variable by simply using the return value. Afterwards you can process the two resulting structures and concatenate the matrices in the first dimension.

    tmp1 = load('Argiris1');
    tmp2 = load('Argiris2');
    
    merged_wkinet = cat(1, tmp1.Wkinet, tmp2.Wkinet)