2

Leveraging Model Comparison to find what you need

 1 year ago
source link: https://blogs.mathworks.com/simulink/2023/02/01/leveraging-model-comparison-to-find-what-you-need/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Today I want to share an example of how I sometimes use Model Comparison to answer questions about Simulink blocks or models. While this is obviously a key part of the workflow to merge branches in a project under source control as I described in Three-Way Model Merge and Git, model comparison can also be used to answer subtle "how-to" questions.
Let's look at a simple example question I received today and how I used model comparison to answer it.

The Question

The question I received today is:
"Hi Guy, do you know of a programmatic way to flip a block on the horizontal axis?"
I did not know the response off the top of my head, but here is how I figured it out.

Before and After

The first thing I do in this kind of situation is making an example to confirm my understanding of the question. For that, I created a simple Subsystem with a few ports all around and masked it to make the behavior as obvious as possible.
ModelComparison_1.png
Then I made the requested modification interactively, using the Format Tab of the toolstrip:
ModelComparison_2.png

Comparing Before and After

I saved two versions of this simple model, one before the change, and one after. Then I simply right-clicked on the two files in the Current Folder Browser and selected Compare Selected Files/Folders:
ModelComparison_3.png
In the comparison results, I disabled the filter for Nonfunctional Changes and I could immediately identify the two parameters needed to flip a block horizontally:
ModelComparison_4.png

Validating the Results

To confirm that the parameters identified by the Model Comparison were what I needed, I wrote this simple script:
FlipExample2.gif

Now it's your turn

Are you sometimes using the Model Comparison tool to identify subtle differences between blocks, Subsystems or models? Or to find the parameter you are looking for?
Let us know in the comments below.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK