the problem to generate a matrix in C + + code by Matlab coder

Hello every one, I wish that you are very nice, because me I dont think that I am :( .
Since a week , I had try to generate a C++ code from code Matlab using Matlab Coder. So I defined a function on Matlab, and it has a (matrice [3][3], double) like Input (Of course I defined the type of Matrice in tollbox properties of Matalb coder) and returned a function has same dimension and type like Input matrice, But the problem, the code generated by Matlab coder, has a function that it has a Array[9] (3*3) like input and output parameter.
so I ask If it possible that make it generated Matrice[3][3] as it define in Matlab code ?
Thank you in advance for your help

 채택된 답변

Fred Smith
Fred Smith 2012년 5월 24일

0 개 추천

There is no way to get MATLAB Coder to generate multi-dimensional arrays in C. This usually is not a practical problem. For most purposes A[3][3] and A[9] and *A behave largely the same in C. For example you can pass any one of these to a function expecting any of the others.
Why do you care about the format?
Regards,
Fred

댓글 수: 3

Hi Fred.
Thank you for your answer. I don't care about the format, but I said , it will be easy if it possible the generate a mult-dimensional arrays :). So you said , I can pass A[3][3] to a function that it define with A[9] as parameter ?
Yes. At most I think you may get a C compiler warning. You can silence the warning with an appropriate cast (double *) of the A[3][3] argument. This cast does not generate any code, it just makes the warning go away.
Thank u Fred very much for your help :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

질문:

2012년 5월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by