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 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.
Then I made the requested modification interactively, using the Format Tab of the toolstrip:
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:
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:
Validating the Results
To confirm that the parameters identified by the Model Comparison were what I needed, I wrote this simple script:
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.
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.