Is there a way to find missing .m files for referenced functions?

A runtime error at runtime when the Matlab interpreter interprets a function that is not implemented in the .m file. Is there any way to find these errors at compile time, i.e. Is there a script that parses my matlab code, checks all the called functions and tells me which .m files are missing (regarding my specific paths)

+4
source share
1 answer

Quick answer: None.

Depfun would be my first guess as a solution to this problem, but it gives you a list of dependencies that exist on the path, and not those that don't exist. Similarly, mlint and mlintmex are not as useful for this as I would hope.

I believe the reason for this is this: the syntax for function calls and indexes is identical in MATLAB.

The only way to find out if foo (bar) is a function call for "foo.m" or an attempt to index into the "foo" matrix is ​​to execute the code to this point and see if the "foo" matrix exists in scope and / or if foo .m exists on the way. If they exist, then MATLAB precedence rules decide whether the "foo" character will be considered as a function call or as a signature operation.

In the following toy example, the expression "ambiguous (1: 9)" is first processed as a function call, and then as a signature operation:

function test disp( ambiguous( 1:9 ) ) ambiguous = 'data item'; disp( ambiguous( 1:9 ) ) end function szMsg = ambiguous( anArgument ) szMsg = 'function call'; end 

You can also create variables using eval and evalin , and also control the MATLAB path to transfer m files to and from scope. These reasons are all conspired to make the solution to this problem impractical (and possibly even impossible) for the general case.

+2
source

Source: https://habr.com/ru/post/1347208/


All Articles