I have two mat files named databaseA.mat and datalabelB.mat which have different sizes, databaseA.mat is 8100 x 80 double and datalabelB.mat is 1 x 80 double. I need to combine them into one mat file but don't change their size. Actually I have combined them with the following code
ALoad = load( 'databaseA.mat' );
BLoad = load( 'datalabelB.mat' );
save( 'databaseAB.mat', 'ALoad' );
save( 'databaseAB.mat', 'BLoad', '-append' );
but result "struct" type data, whereas I don't desire it. Could you correct it? Thank you for your help.

 Accepted Answer

Adam
Adam on 13 Oct 2016
Edited: Adam on 13 Oct 2016
ALoad = load( 'databaseA.mat' );
BLoad = load( 'datalabelB.mat' );
a = ALoad.a;
b = BLoad.b;
save( 'databaseAB.mat', 'a', 'b' );
Using load with a return value will give you a struct with your data in it, but you can just get the data out of the struct. You can also do this in other ways, probably neater, but this should work and if it is a one-off operation efficiency or neatness doesn't really matter.

2 Comments

I tried it, but gives me an error
Reference to non-existent field 'a'.
Error in combineAB (line 8)
a = ALoad.a;
Adam
Adam on 13 Oct 2016
Oh yeah, I forgot to say I have no idea what your matrices are actually called in the mat files so I just used 'a' and 'b' as placeholders. Just replace them with whatever your matrix variables are called in each file.

Sign in to comment.

More Answers (0)

Categories

Products

Asked:

on 13 Oct 2016

Commented:

on 13 Oct 2016

Community Treasure Hunt

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

Start Hunting!