Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

visdiff - Compare two text files, MAT-Files, or binary files

GUI Alternative

As an alternative to the visdiff function:

  1. Select Desktop > File and Folder Comparisons.

  2. In the File and Folder Comparisons tool select one of the following:

    • File > New File Comparison

    • File > New Folder Comparison

Syntax

visdiff('fname1', 'fname2')
visdiff('fname1', 'fname2', showchars)
S = visdiff('fname1', 'fname2')

Description

visdiff('fname1', 'fname2') opens the File and Folder Comparisons tool and presents the differences between the two files. The two files must be on the MATLAB path, or you must provide the full path for each file.

visdiff('fname1', 'fname2', showchars) opens the File and Folder Comparisons tool with the width of each column in the display set to showchars characters wide. MATLAB ignores the showchars option when you compare two binary files or two MAT-Files.

S = visdiff('fname1', 'fname2') creates an HTML report describing the differences between the two files and returns it in the string S.

Remarks

MATLAB supports displaying the differences in the File and Folder Comparisons tool only if Java software is installed. However, MATLAB supports assigning the HTML report to a string, even if the Java software is not installed.

Examples

Compare Two Text Files in the Current Folder

Compare the example files, lengthofline.m and lengthofline2.m and set the width of each column to 50 characters wide. :

visdiff(fullfile(matlabroot,'help','techdoc','matlab_env',...
'examples','lengthofline.m'), fullfile(matlabroot,'help',...
'techdoc','matlab_env','examples','lengthofline2.m'), 50)

Compare Two MAT-Files Off the MATLAB Path

Compare two binary files that are on the MATLAB path.

visdiff(fullfile(matlabroot,'toolbox','matlab','demos','gatlin.mat'), ...
fullfile(matlabroot,'toolbox','matlab','demos','gatlin2.mat'))

Compare Two Binary Files on the MATLAB Path

Add the folder containing two MEX-files to the MATLAB path, and then compare the files, by issuing these commands:

addpath([matlabroot '\extern\examples\shrlib'])
visdiff('shrlibsample.mexw32', 'yprime.mexw32')

The File and Folder Comparisons tool opens and indicates that the files are different, but does not provide details about the differences.

See Also

Comparing Files and Folders

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS