Why does "matlab.co​detools.re​quiredFile​sAndProduc​ts" find a syntax error in MathWork code?

Hello all,
I tried to find the dependencies of a function/program I wrote, in order to clean up the folder of this program. The exectution of
[fList,pList] = matlab.codetools.requiredFilesAndProducts('myOwnFunction.m');
stops with an error I really do not understand:
Error using matlab.codetools.requiredFilesAndProducts (line 91)
MATLAB code 'C:\Program Files\MATLAB\R2021b\toolbox\coder\half\@half\half.p' contains the following syntax error(s):
Line 0 column 0 : Unable to open file 'C:\Program Files\MATLAB\R2021b\toolbox\coder\half\@half\half.p'. File is not a supported MATLAB code file.
How can I fix this issue?

3 个评论

Can you post your M file? Does that file try to call a function called "half" which does not exist?
Hi Benjamin,
unfortunately, I can't post the M file, as it is a function with many extra files, functions and subfunctions developed over the last years.
I made a string search in the whole code and it seems the code itself doesn't call the "half" function. So I tink it is the matlab coder who tries to call the function.
The function "half" exists in the folder, where matlab expects it.
Can you try to make a MWE? Make a copy of the project and start deleting code until the error disappears. That way you can determine which code is leading to this error.

请先登录,再进行评论。

 采纳的回答

Yesterday, I used Rik's idea of a MWE, which is very easy in case of
matlab.codetools.requiredFilesAndProducts
. You can just comment out big parts of the code, as it is no need to led the code "run".
It took me the whole day, but I figured out, that just 2 simple typos deep in the code produced this error. They had nothing im common with the message of the error...
First problem was a written "NAN" instead of "NaN"
Second problem: one of the programmers defined the variable: "COS" (which is indeed not very clever to do... ), and used it in several scripts. Whereas matlab R2014a was fine with it, R2021b was somehow confused.

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 MATLAB Coder 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by