필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

matlab to c

조회 수: 2 (최근 30일)
ECE09 ITBHU
ECE09 ITBHU 2011년 7월 28일
마감: MATLAB Answer Bot 2021년 8월 20일
I converted a function using matlab using matlab coder. in .m file i had declared:----
>> a.b = 37000; a.c = 8;
but as output in .c file i got:----
>>a.b=34000.0 a.c =7.0
? why has the values changed?
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2011년 7월 28일
Could you include a simple code snippet that we can use to reproduce the issue. It might also help to mention the command you used to generate code, as well as the MATLAB version.

답변 (2개)

Walter Roberson
Walter Roberson 2011년 7월 28일
Do those variables happen to be loop control variables in a context where they are incremented by 3000 and 1 respectively before they are used?
  댓글 수: 2
ECE09 ITBHU
ECE09 ITBHU 2011년 7월 29일
No , they aren't. i am making a simple function which outputs a structure named " a ".
Arnaud Miege
Arnaud Miege 2011년 7월 29일
As previously asked, can you post a code snippet and the command used to generate the code, so that we can reproduce the issue?

Mike Hosea
Mike Hosea 2011년 8월 1일
I echo the requests for more of the code. However, let me just point out that MATLAB Coder performs some optimizations. If you had code like this
n = 1;
if ~isreal(x)
n = n + 1;
end
You will probably see
n = 2.0;
generated if x is not real. Is it possible that after your assignment there are statements that the compiler can evaluate during compilation because the values/conditions are already known? -- Mike

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by