Why are extra C++ classes being generated from my MATLAB Code?

1 view (last 30 days)
我定义了一个MATLAB类和两个入口点functions that call members of it. The output of the first function is an instance of the class and is used as an argument to the second function. When I generate code, I expect to see a single C++ class that mimics the structure of the MATLAB class. Instead, I see an extra class being generated, with a 'b_' prepended to its name. Why does this happen?

Accepted Answer

MathWorks Support Team
MathWorks Support Team 2021年2月19日
Edited:MathWorks Support Team 2021年2月19日
One possible reason for this is that the input of the second function and the output of first function are not explicitly connected in the MATLAB Coder app. Therefore, these two arguments are treated as two separate class types. Make sure to establish the relationship between the two using coder.OutputType function or in the MATLAB Coder app, click the input of the 2nd function and choose "Use output" then choose the output of the first function.
In the "Define Input" stage, choose "Use output".
Choose the output of the first function.

More Answers (0)