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

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
Tobias
Tobias il 12 Gen 2023
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.
Rik
Rik il 12 Gen 2023
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.

Accedi per commentare.

Risposta accettata

Tobias
Tobias il 13 Gen 2023
Modificato: Tobias il 13 Gen 2023
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.

Più risposte (0)

Categorie

Scopri di più su MATLAB Coder in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by