Search code examples
htmlmatlabdiffmat-file

How to programatically save MATLAB comparison results from visdiff and reload them into the GUI or save as HTML?


The comparison tool visdiff(file1.m,file2.m) report displays the files file1.m and file2.m side by side, and highlights the lines that do not match.

In the GUI that pops up you could click and Save comparison report as HTML.

You could have assigned the value to a variable, for example, myDiff = visdiff(file1.m,file2.m);

And then save myDiff as a .mat with save(myVisDiff,myDiff);, which by definition is not an HTML, and I do not know how I would load it back to be visually inspected.

How could I programatically save the HTML as HTML produced by visdiff(file1.m,file2.m) or visually display the same GUI originally created by visdiff if myDiff were stored as a .mat?


Solution

  • What you received from visdiff is HTML, everything left to do is to write it to a file:

    fid=fopen('diff.html')
    fwrite(fid,myDiff,'char')
    flose(fid)
    

    If you wish you could also use the matlab built-in browser to display the results:

    web(['text://',myDiff])