Function return types in Matlab Coder

29 次查看(过去 30 天)
Hello, I am investigating the Matlab Coder functionality. I have 2 quick questions let's say I have the following function in Matlab:
function int_point = my_cross(line1,line2)
int_point = cross(line1,line2);
end
The corresponding C++ function generated by the coder is the following:
void my_cross(const double line1[3], const double line2[3], double int_point[3])
{
int_point[0] = line1[1] * line2[2] - line2[1] * line1[2];
int_point[1] = line2[0] * line1[2] - line1[0] * line2[2];
int_point[2] = line1[0] * line2[1] - line2[0] * line1[1];
}
Question 1) Is there a way to have the c++ function having return type double instead of returning as parameter?
Question 2) In the generated c++ function where my_cross is called the parameters are passed by pointer but I want to pass by value. Can I change this behaviour?
Thanks.

回答(1 个)

Mukund Sankaran
Mukund Sankaran 2023-6-14
Hello,
Another similar question was posed a while ago, and the answer there contains some more specifics as well: https://www.mathworks.com/matlabcentral/answers/781348-matlab-coder-generated-a-c-function-which-has-void-output-even-though-the-matlab-function-has-doubl
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by