Also, the mat files can contain NaN values, but if I use isequaln it will still give me a '0' even though they are identical.
isequal vs. visdiff for .mat files?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John R.
el 19 de Ag. de 2015
Comentada: Walter Roberson
el 19 de Ag. de 2015
Hello,
I'm trying to compare two mat files to see if there are any differences between them. These mat files contain inputs and outputs of a trajectory model I've created, and are comprised of structures, strings, doubles, cells, etc.
When I use isequal, it returns a '0' indicating they are not equal. But when I use visdiff to compare them it does not find any differences.
visdiff says " The variables in these files are identical, but the files are not. The differences may be caused by file formats, file timestamps, or the order in which the variables are stored."
The variables are in the same order. What is the timestamp? Can it be ignored?
Thank you.
Respuesta aceptada
Walter Roberson
el 19 de Ag. de 2015
Timestamps can be ignored. If you were to save the same data twice, it would record the time of each save and so the files would not be identical.
However, how are you using isequal() on the .mat files? Are you load()'ing the content and using isequal() on the structures, or are you using isequal() on the file names ?
2 comentarios
Walter Roberson
el 19 de Ag. de 2015
First dir() the two files and compare their sizes. If the sizes differ then the files must be different (but the difference might not be important)
After that you could hash each of the files and compare the hash http://www.mathworks.com/matlabcentral/fileexchange/31272-datahash
Or you could fileread() each of the files and isequal() the result, if you have enough memory.
The advantage of using fileread() is that you could zero the bytes that are used for the timestamp, against the possibility that the same data was saved twice exactly the same way.
You can also use whos with the -file option and isequal() the structures that result, to determine whether there is a difference in the names of variables or their sizes or class. A step beyond that would be to sort that by variable name, if you want to deal with the possibility that the same data was stored but with a difference in the order of the variables.
Identical whos does not promise that the files are identical.
Más respuestas (0)
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!