Guy and Seth on Simulink

Results for: Debugging

Problems with your S-Functions… Try this Diagnostic! 1

Posted by Guy Rouleau,

Problems with your S-Functions… Try this Diagnostic! Ahhh... C Mex S-function... If you ever tried creating a C Mex S-function and were a little rusty on your C programming, you might have experienced strange behavior or event MATLAB crashes. This is possible... C Mex S-Functions let you do almost anything you can think of, including shooting yourself... read more >>

Quickly Switching Model Configuration Sets 6

Posted by Guy Rouleau,

Quickly Switching Model Configuration Sets During the life of a model, you will very likely need to change many configuration parameters to complete different tasks. For example, when debugging you want to enable many run time diagnostics to catch modeling errors. When the model is well tuned and you want to use it for a... read more >>

Defining custom shortcuts in Simulink 1

Posted by Guy Rouleau,

Defining custom shortcuts in Simulink On this blog, I sometimes highlight features that it took me a while to appreciate and include in my daily workflow. I hate to admit it, but quite often those are features that I was aware of for a long time, but for various reasons I was scared of using. Most... read more >>

Comparing Runs using Simulation Data Inspector 13

Posted by Guy Rouleau,

Comparing Runs using Simulation Data Inspector Do you use the Simulation Data Inspector? Here is an example where it saved me a lot of debugging time. Simulation Accuracy I recently had to validate system behavior and analyze numerical accuracy of a model. Making small modifications in one part of the model was leading to unexpectedly large differences at... read more >>

Zero-Crossing Detection… what are your options? 1

Posted by Guy Rouleau,

Zero-Crossing Detection… what are your options? When using Simulink variable-step solvers, zero-crossing detection is very useful to capture events accurately. However for some equations, configuring zero-crossing detection can be challenging. Last week I received the following question and example model: In the attached model, I implemented a basic bang-bang controller for a plow. Using a Sign block, I... read more >>

To Latch or not to Latch?

Posted by Guy Rouleau,

To Latch or not to Latch? Yesterday I explained to a colleague the effect of the Inport block option Latch input for feedback signals of function-call subsystem outputs . I thought it would be interesting to share here. The Problem In the following model, inside the calib function-call subsystem, the Count signal is connected to a Unit Delay block. When... read more >>

Data Dependency Violation Errors and Subsystem Semantics 1

Posted by Guy Rouleau,

Data Dependency Violation Errors and Subsystem Semantics Did you ever receive a "data dependency violation" error message from a Simulink model? I will try to explain why this happens and what you need to do to avoid this error by introducing my favorite set of Simulink examples. Function-Call Subsystems To begin, let's explain how a Function-Call Subsystem is executed. In the... read more >>

Debugging C/C++ S-Functions 1

Posted by Guy Rouleau,

Debugging C/C++ S-Functions If you are going to work with C or C++ S-Functions, you will probably need to do some debugging. My advice is: Don't go with the printf debugging approach. I did that for too long and now I realize it was a waste of my time. Once you discover how... read more >>

An Ounce of Design Min/Max is Worth…

Posted by Guy Rouleau,

An Ounce of Design Min/Max is Worth… Often, it is worth putting a bit of extra effort at the beginning of a project to save time later. Today I want to introduce a feature that gets more useful with every release of Simulink, but unfortunately I think very few people use it: Signal Ranges How do Signal Ranges work? In... read more >>

These postings are the author's and don't necessarily represent the opinions of MathWorks.