File Exchange

image thumbnail

Compare two .mat files

version 1.0.0.0 (16.8 KB) by Xianyao Chen
Compare two .mat files and display the contents and difference of mat files.

9 Downloads

Updated 10 Jun 2004

No License

Compare two mat files,

useage: matc matfile1.mat matfile2.mat

it will show three different releationship between the variables stored in mat file:

not exist, not equal, equal.

Although one can use
A = load matfile1;
B = load matfile2;
isequal(A,B)
to determine if two mat files are exactly same, it can not help one determine which variable in matfile1 is different or does not exist in matfile2.

Example:

matc aa.mat bb.mat
Source File: aa.mat --- Target File: bb.mat
--------------------------------------------------
Variable :: a || not exist
Variable :: b || equal
Variable :: c || not equal
--------------------------------------------------

Source File: bb.mat --- Target File: aa.mat
--------------------------------------------------
Variable :: ab || not exist
Variable :: b || equal
Variable :: c || not equal
--------------------------------------------------

Cite As

Xianyao Chen (2021). Compare two .mat files (https://www.mathworks.com/matlabcentral/fileexchange/5160-compare-two-mat-files), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (13)

Naveen Reddy

Error: matc.p was generated prior to MATLAB version 7.5 (R2007b) and is no longer supported. Use pcode to regenerate the
file using MATLAB R2007b or later.
Can some one suggest how to resolve

João Morais

Perfect.

Dejan Vujatovic

jorge Perez

Richard

I had tons of trouble with this, it even appeared to mess up my search path. I switched to using the one by Michael Arant instead which worked right out of the box.

Samuel Maliva

Very helpful

Please can I get the test function to compare aa.mat and bb.mat

Wenjie

Very useful !
It's easy to use and helps a lot.

Jochen Rau

Very useful. Thanks!
Another nice extension would be to integrate sth like submission #22752 (recursive comparison of structures) if a variable is a structure.

Natalia

Excellent, thank you!

Mohammed

good one

HOng T

concise.

Dadi Gudmundsson

Simple, effective, useful.

Helps Alot

Thank you so much

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!