File too complex to analyze, function maybe too large?

Hello,
I have 5 functions which I'm translating from matlab to a dll (fregCentrCorGCpp.m), then I load it in my c++ visual studio project. I'm trying to convert this specific function but I'm strugling with this error that I get everytime I use the coder tool from matlab.
The file is too complex to analyze. Simplify the code to improve code maintainability. For example, reduce the number of operations in expressions.
I attached my m file, dont know what I can do to solve the problem.
For example I successed translating other functions such as "fregM.m" file, also attached.
Which is the difference? maybe too many variables?

3 件のコメント

Image Analyst
Image Analyst 2023 年 2 月 27 日
"fregM.m" is not attached yet.
Walter Roberson
Walter Roberson 2023 年 2 月 27 日
Why do you create an anonymous function and then immediately call the function? Why not have the code just be the function?
It looks to me as if you created a function using matlabFunction() applied to an expression that used a bunch of floating point numbers that you permitted the default symbolic conversion for, instead of being careful to convert the floating-point numbers. You would probably have achieved a smaller function if you had converted the floating-point more carefully.
Mikel
Mikel 2023 年 2 月 27 日
@Image Analyst my fault! I meant fregMCpp.m

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2023 年 2 月 27 日
編集済み: Jan 2023 年 2 月 27 日

0 投票

Try a simplified version:
  • Calculate the function directly instead of creating a huge function handle.
  • Use constants for the most frequently used function and some repeated numbers.
  • Split the expression to different lines.
See the modified attached file.

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2022b

質問済み:

2023 年 2 月 27 日

編集済み:

Jan
2023 年 2 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by