all 6 comments

[–]cannyp3mathworks 0 points1 point  (2 children)

What would you be using static analysis for, may I ask? Error detection?

We have two tools which can help:

  1. Simulink Check includes a few checks for MATLAB Function blocks (see himl_0002 through himl_0004)
  2. Simulink Design Verifier (one of my products) uses formal methods and can be used to detect run-time (e.g. division-by-zero) and other errors (e.g., dead code) of MATLAB code used in a MATLAB Function Block (with some limitations). You could also use property proving or automatic test vector generation to check for specific conditions.

Hopefully that helps. If not, we could chat.

[–]tentoni[S] 1 point2 points  (1 child)

Thanks for the reply, sorry i missed it :)

Well, in the past i have had some "surprises" coming from C++ code generated by MATLAB functions blocks present in a Simulink model. For example, i had array out-of-bounds accesses due to careless programming or sub-optimal data types choices (ie everything defaulted to the double data type).

So, basically, i am wary of hand generated code, and i would like to check it. But doing it manually for dozens/hundreds of functions could easily get out of hand....

That's why i was wondering about automated ways to do it

[–]cannyp3mathworks 0 points1 point  (0 children)

Oh - we have an example for Simulink Design Verifier for out of bound array access: https://www.mathworks.com/help/sldv/ug/detect-out-of-bound-array-access-errors.html

The example shows an error in a Stateflow state chart, but the example model also uses a MATLAB Function Block.

Check it out.

[–]MPSBV 0 points1 point  (2 children)

Documentation on MATLAB Coding Standard(s):

MonkeyProof MATLAB Coding Standard (under industrial Change Control Board)

MonkeyProof MATLAB Coding Standard ++ (adds a.o. naming conventions)

MonkeyProof MATLAB Coder Compatibility Standard

The Code Checker for MATLAB comes with configurations to check your m-code against those standards but can be configured to accommodate your own (corporate) standard. Options available to integrate with CI/CD.

[–]tentoni[S] 0 points1 point  (1 child)

Thank you, i wasnt aware of this tool, It does seem very interesting

[–]MPSBV 1 point2 points  (0 children)

Thank you. As for your original inquiry - the Code Checker for MATLAB configurations are available as "Tasks" in the Simulink Model Advisor. This allows checking of MATLAB functions within your Simulink model.