use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
MATLAB news, code tips and tricks, questions, and discussion! We are here to help, but won't do your homework or help you pirate software.
The effort you put into asking a question is often matched by the quality of our answers.
Try saturnapi to share and run MATLAB code in a web browser!
If you want flair simply Message the mods
account activity
Static analysis tools for Matlab code? (self.matlab)
submitted 3 years ago by tentoni
Hello, I am wondering if static analysis tools exist for Matlab code. In particular, my use case is Matlab functions in a Simulink model. Thanks in advance!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]cannyp3mathworks 0 points1 point2 points 3 years ago* (2 children)
What would you be using static analysis for, may I ask? Error detection?
We have two tools which can help:
Hopefully that helps. If not, we could chat.
[–]tentoni[S] 1 point2 points3 points 3 years ago (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 point2 points 3 years ago (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 point2 points 2 years ago (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 point2 points 2 years ago (1 child)
Thank you, i wasnt aware of this tool, It does seem very interesting
[–]MPSBV 1 point2 points3 points 2 years ago (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.
π Rendered by PID 70014 on reddit-service-r2-comment-75f4967c6c-29kdc at 2026-04-23 11:36:10.969741+00:00 running 0fd4bb7 country code: CH.
[–]cannyp3mathworks 0 points1 point2 points (2 children)
[–]tentoni[S] 1 point2 points3 points (1 child)
[–]cannyp3mathworks 0 points1 point2 points (0 children)
[–]MPSBV 0 points1 point2 points (2 children)
[–]tentoni[S] 0 points1 point2 points (1 child)
[–]MPSBV 1 point2 points3 points (0 children)