Function return types in Matlab Coder

17 vues (au cours des 30 derniers jours)
Kara657
Kara657 le 14 Juin 2023
Commenté : Kara657 le 15 Juin 2023
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.

Réponses (1)

Mukund Sankaran
Mukund Sankaran le 14 Juin 2023
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!

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by