필터 지우기
필터 지우기

'Matlab Coder' generated code is NEVER of double type (only real_T)

조회 수: 17 (최근 30일)
Viren
Viren 2013년 12월 4일
편집: Mike Hosea 2013년 12월 26일
I'm trying to convert a piece of matlab code into C++ code. I have one large vector (100+ elements) as input and one large vector as the output. Now, when I try to build the code using the Matlab Coder, while explicitly specifying that the input variable (u) is a DOUBLE, Matlab just seems to ignore my demands and does its own thing by creating the function with input variable of the type const real_T type instead.
This would not be so bad except that I need to use the resulting code with the Legacy_Code function in order to create an S Function. What can I do?
[Attached screenshot shows what is wrong]

채택된 답변

Walter Roberson
Walter Roberson 2013년 12월 4일
Notice that if you do not include the include file indicated there, you could go ahead with the legacy code tool and create the equivalence: http://www.mathworks.com/help/simulink/slref/legacy_code.html
legacy_code('compile', specs, compilerOptions)
example:
legacy_code('compile', s,...
{'-DCOMPILE_VALUE1=1', '-DCOMPILE_VALUE2=2',...
'-DCOMPILE_VALUE3=3'});
So you could '-Dreal_T=double'
  댓글 수: 1
Mike Hosea
Mike Hosea 2013년 12월 26일
편집: Mike Hosea 2013년 12월 26일
The type real_T is already double. It is not float, which would be real32_T.

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

추가 답변 (3개)

Ryan Livingston
Ryan Livingston 2013년 12월 5일
Also if you are using MATLAB Coder in R2013b, you can request that C built-in types be used in the generated code for LIB, DLL and EXE targets:
That will use 'double' rather than 'real_T' in the generated code.

Viren
Viren 2013년 12월 4일
Ah. Makes sense. I actually knew that real_T was the catch-all data type that matlab has, and I was making another error in my code. Never mind that. Thanks for your prompt reply. Answer accepted.

Viren
Viren 2013년 12월 5일
That's even more useful. This is what I should have done in the first place. I must say I had nearly given up on the Matlab community, but you guys have saved the day! Thanks very much.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by