??? Type mismatch: embedded.fi
15 views (last 30 days)
Show older comments
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 Comment
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!