How to properly using visdiff in command line with mat files ?

13 ビュー (過去 30 日間)
Elie Lusseau
Elie Lusseau 2023 年 2 月 21 日
編集済み: Elie Lusseau 2023 年 2 月 21 日
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 件のコメント
Fangjun Jiang
Fangjun Jiang 2023 年 2 月 21 日
What do you try to do by "tempname(tmpfolder)"??
Elie Lusseau
Elie Lusseau 2023 年 2 月 21 日
tmpfolder = tempname;
file1 = horzcat(tempname(tmpfolder), '.mat');
Is used to create a file in a temp folder that I will be able to delete at the end.
tempname create a folder in %temp% with a unique name.
tempname(tmpfolder) create a unique file name in the said folder.

サインインしてコメントする。

回答 (1 件)

chrisw23
chrisw23 2023 年 2 月 21 日
try to start a new MatLab session
modify this cmd line as needed
matlab -wait -nodesktop -r "visdiff( \"\"{<file1>}\"\",\"\"{<file2>}\"\")"
  1 件のコメント
Elie Lusseau
Elie Lusseau 2023 年 2 月 21 日
Thanks for the answer
By modifying the command this way :
system(['matlab -wait -nodesktop -r "visdiff(''', file1, ''', ''', file2, ''')'])
I manage to run a proper separate matlab environment.
Unfortunately, I retrieve an error pop-up (not in command windows) :
Error : Connector is not running. Use connector.ensureServiceOn() to ensure it is running before using it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by