MATLAB: Fixed point coder log10 implementation

fixed point matlab coder log10 unsupportedmatlab coder

I am using 20*log10(val) to get power in a dB
y = 20*log10(3)
But When i am using matlab coder to convert the in c/c++ code.I am gettig an error
Function 'log10' is not defined for values of class 'embedded.fi'.
Can someone help me with alternate way of doing dB calculation.
Thank you

Best Answer

qsb = fixed.Quantizer(numerictype(1,32,24));
y0 = quantize(qsb,20*fi(log(double(x)),1,32,24)/fi(log(double(10)),1,32,24)); % log(x)/log(10) for log base 10 i.e. log10
y1 = 20*log10(x);