buildInstrumentedMex gives "Unknown exception"

6 Ansichten (letzte 30 Tage)
Bert RAM Aerts
Bert RAM Aerts am 21 Feb. 2016
Bearbeitet: Bert RAM Aerts am 23 Feb. 2016
In the following code, the statement with buildInstrumentedMex gives the error "Unknown exception" while fiaccel is working fine. So the code generation must be OK. I do not have a license for code generation, but the examples from the Fixed Point Designer Getting Started Guide with buildInstrumentedMex are working fine. What am I missing?
T = mytypes('9Q23');
Hinp = cast(ones(2,2)+1j*ones(2,2),'like',T.x);
fiaccel inv4fix -args {Hinp,T} -o fiaccelinv4fix_mex
H1 = cast([ 0.1+1j*0.2 0.3+1j*0.4; 0.5+1j*0.6 0.7+1j*0.8 ],'like',T.x);
H1inv = fiaccelinv4fix_mex(H1,T);
buildInstrumentedMex înv4fix -args {Hinp,T} -histogram -o inv4fix_mex
where
% mytypes.m
function T = mytypes(dt)
switch dt
case '9Q23'
F = fimath('RoundingMethod', 'Nearest', ...
'OverflowAction', 'Saturate', ...
'ProductMode', 'SpecifyPrecision', ...
'ProductWordLength', 32, ...
'ProductFractionLength', 23, ...
'SumMode', 'SpecifyPrecision', ...
'SumWordLength', 32, ...
'SumFractionLength', 23, ...
'CastBeforeSum', true);
T.x = fi([],true,32,23,F);
end
end
% inv4fix.m
function Hinv = inv4fix(H,T) %#codegen
if size(H,1)==2;
% inverse of [a b; c d] is 1/(ad-bc) [d -b; -c a]
% fixed point types
Tdiv = numerictype('Signed',true,'WordLength',T.x.WordLength,'FractionLength',T.x.FractionLength);
% real algorithm
a = cast(H(1,1),'like',T.x);
b = cast(H(1,2),'like',T.x);
c = cast(H(2,1),'like',T.x);
d = cast(H(2,2),'like',T.x);
factor = cast((a*d - b*c),'like',T.x);
% 1/(a+1j*b) = (a-1j*b)/(a^2+b^2)
factor_r = cast(real(factor),'like',T.x);
factor_i = cast(imag(factor),'like',T.x);
denominator = cast(factor_r*factor_r + factor_i*factor_i,'like',T.x);
factor_r = divide(Tdiv,factor_r,denominator);
factor_i = divide(Tdiv,factor_i,denominator);
Hinv = [d -b; -c a];
Hinv = cast((factor_r-1j*factor_i) * Hinv,'like',T.x);
else
Hinv = H;
end
end

Akzeptierte Antwort

Bert RAM Aerts
Bert RAM Aerts am 22 Feb. 2016
Bearbeitet: Bert RAM Aerts am 23 Feb. 2016
Having two operating systems Windows 10 and Mageia 5 Linux helps sometimes... While Matlab R2015b in Windows 10 was just giving "unknown exception", Matlab R2015b in Mageia 5 was giving a clear reason "înv4fix is not a valid function name" ... Only then I saw that the first letter was not an i but î. Replacing it by a normal letter i solved this issue.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by