??? Type mismatch: embedded.fi

조회 수: 10 (최근 30일)
Roman Foell
Roman Foell 2020년 4월 1일
댓글: Sheng Kwei Tai 2021년 9월 13일
Hello,
I want to convert Matlab code to c code in fixed-point format.
After I want to convert to fixed point, I get this error:
??? Type mismatch: embedded.fi {sfix51_En24}[:? x :?] ~= embedded.fi {sfix16_En6}[:? x :?].
Error in ==> start_fixpt Line: 97 Column: 9
Code generation failed: View Error Report
The line 97 is the code created from Matlab itself, here the else condition from the function fi_div:
function c = fi_div(a,b)
coder.inline( 'always' );
if isfi( a ) && isfi( b ) && isscalar( b )
a1 = fi( a, 'RoundMode', 'fix' );
b1 = fi( b, 'RoundMode', 'fix' );
c1 = divide( divideType( a1, b1 ), a1, b1 );
c = fi( c1, numerictype( c1 ), fimath( a ) );
else
c = a / b;
end
end
The lines fi_div is used is
ATA = fi([fi(w(1), 0, 16, -1, fm), w(2), w(3), w(4); fi(w(2), 0, 16, -1, fm), w(3), w(4), w(5); fi(w(3), 0, 16, -1, fm), w(4), w(5), w(6);fi(w(4), 0, 16, -1, fm), w(5), w(6), w(7)], 0, 16, -1, fm);
% solve system of equations
div_temp1 = fi((data.y * W(:,n+fi(1, 0, 1, 0, fm):fi(end, 0, 11, 0, fm))), 1, 16, 5, fm);
div_temp2 = fi((data.yy * W(:,n+fi(1, 0, 1, 0, fm):fi(end, 0, 11, 0, fm))), 0, 16, 6, fm);
p = fi(fi_div(div_temp1, ATA), 1, 16, 14, fm);
pp = fi(fi_div(div_temp2, ATA), 1, 16, 14, fm);
How can I fix this type of error while creating c code in fixed-point format?
Thanks in advance.
  댓글 수: 1
Sheng Kwei Tai
Sheng Kwei Tai 2021년 9월 13일
Did you solve this probelm?
I also had the same problem

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by