필터 지우기
필터 지우기

Function return types in Matlab Coder

조회 수: 16 (최근 30일)
Kara657
Kara657 2023년 6월 14일
댓글: Kara657 2023년 6월 15일
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