Main Content
Resolve Error: Mismatched fimath
Issue
If two fi
object operands have an attached
fimath
, the fimath
s must be equal.
Possible Solutions
Use the removefimath
function to remove
the fimath
of one of the variables in just one instance. By
removing the fimath
, you avoid the “mismatched
fimath
” error without permanently changing the
fimath
of the variable.
Original Algorithm | New Algorithm |
---|---|
Function: function y = mysum(x,T) %#codegen y = zeros(size(x), 'like', T.y); for n = 1:length(x) y(:) = y + x(n); end end | Function: function y = mysum(x,T) %#codegen y = zeros(size(x), 'like', T.y); for n = 1:length(x) y(:) = removefimath(y) + x(n); end end |
Types Table: function T = mytypes(dt) switch(dt) case 'fixed' T.x = fi([],1,16,0, 'RoundingMethod', 'Floor',... 'OverflowAction','Wrap'); T.y = fi([],1,16,0, 'RoundingMethod','Nearest'); end end | Types Table: function T = mytypes(dt) switch(dt) case 'fixed' T.x = fi([],1,16,0, 'RoundingMethod','Floor',... 'OverflowAction','Wrap'); T.y = fi([],1,16,0, 'RoundingMethod', 'Nearest'); end end |
See Also
removefimath
| fimath
| fi