java.lang.​IllegalSta​teExceptio​n: com.mathwo​rks.compar​isons.exce​ption.Comp​arisonExce​ption: Unable to find file

3 views (last 30 days)
I am trying to compare two MATLAB 2021b .slx models
I get this error and couldn't fo it.
what might be the reason and how to fix it?

Answers (1)

Harsh
Harsh on 12 Jun 2025
Edited: Harsh on 12 Jun 2025
The java.lang.IllegalStateException error in MATLAB's Comparison Tool typically means it can't find your .slx model files. This is often due to an incorrect path, missing files, or permission issues.
To resolve this issue, I recommend trying the following troubleshooting steps:
  • Verify file location, confirm that both .slx files are exactly where you expect them to be.
  • Check read permissions, ensure the files are not locked and that you have the necessary read permissions.
  • Update MATLAB path, add the folder containing your models to the MATLAB path.
Once it is confirmed that the files are accessible, you can use the Comparison Tool to explore the differences, view the changes highlighted in the original models, and merge differences. See the following documentation page for more information and examples on how to use Simulink Model Comparison:
https://www.mathworks.com/help/simulink/ug/compare-simulink-model-files.html
There are three ways to initiate the comparison:
  • Select two Simulink models at once (e.g., by holding down the Ctrl key while selecting one file after another in the “Current Folder” pane of MATLAB), then right-click the selection. In the menu that appears, select “Compare Selected Files/Folders.”
  • Alternatively, you may select one of the Simulink models, right-click, and choose “Compare Against” > “Choose…”, then select the second Simulink model from the file browser in the “Selecting Files or Folders for Comparison” dialog box.
  • Click on the “Compare” button in the MATLAB toolstrip under the “File” section. In the “Selecting Files or Folders for Comparison” dialog box, use the file browser to select the two Simulink model files for comparison.
If the error persists after these steps, please share the complete log file and the reproduction steps.
I hope this helps, thanks!

Categories

Find more on Interactive Model Editing in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!