How to properly using visdiff in command line with mat files ?
13 views (last 30 days)
Show older comments
Hello all,
I am trying to compare m files that contains parameters that are not stored in specific lines.
The only way to do so I found is to :
- Run the first m file manually and save resulting workspace in a first mat file
- Run the second m file manually and save resulting workspace in a second mat file
- right clic with both selected and use compare option
- Analyse the differences (my real goal/activity)
- Deleting the mat files
As the overall process of having a GUI is a pain and not really adding value, I am trying to automating evrey step.
But when programmatically compare 2 sets of matlab variables that are stored in temporary mat files.
(My code stores the files in a temp directory so that once the comparison is done, I can delete them.)
Here is a simplified version of my code :
tmpfolder = tempname;
file1 = horzcat(tempname(tmpfolder), '.mat');
file2 = horzcat(tempname(tmpfolder), '.mat');
% file1 and file2 are filled with data
visdiff(file1, file2);
% want to wait here
rmdir(tmpfolder, 's');
The difficulty is that as soon as I run the rmdir command, the visdiff interface freeze and the result of the comparison even does not show up.
Am I doing something the wrong way ?
(Maybe visdiff is not the right tool)
Is there a way to make my code wait for the finished comparison to go to the rmdir command ?
(I already tried the pause(N) and a loop based on desktop = com.mathworks.mde.desk.MLDesktop.getInstance(); but both does not work)
Thanks in advance.
Best regards.
2 Comments
Answers (1)
chrisw23
on 21 Feb 2023
try to start a new MatLab session
modify this cmd line as needed
matlab -wait -nodesktop -r "visdiff( \"\"{<file1>}\"\",\"\"{<file2>}\"\")"
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!