Fixed point coder log10 implementation
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (2)
Darshan Ramakant Bhat
el 19 de Nov. de 2020
0 votos
The function "log10" is supported for code generation in the latest version (R2020b) of MATLAB. You can find the list of supported functions in the below page :
1 comentario
Life is Wonderful
el 19 de Nov. de 2020
Life is Wonderful
el 20 de Nov. de 2020
6 comentarios
Darshan Ramakant Bhat
el 20 de Nov. de 2020
I tried with the below function and it worked in my MATLAB
function y = myLogFunc(x)
y = 20*log10(x);
end
>> codegen -config:lib myLogFunc -args {3} -report
Code generation successful: View report
Please provide me your sample function along with the script to reproduce the issue.
Life is Wonderful
el 20 de Nov. de 2020
Editada: Life is Wonderful
el 20 de Nov. de 2020
Darshan Ramakant Bhat
el 20 de Nov. de 2020
Thanks for attaching the sample script and explaining the issue clearly. I completely missed the fixed point conversion part earlier.
The error is happening because the function "log10()" cannot take the fixed point inputs. If you do "log10(fi(3))" it will error out.
I found below documentations on fixing such errors :
Based on the above doc I modified the function like below :
function y = compute_log(x)
%#codegen
y = 20*fi(log(double(x)),1,16,0);
end
Life is Wonderful
el 20 de Nov. de 2020
Editada: Life is Wonderful
el 20 de Nov. de 2020
Life is Wonderful
el 20 de Nov. de 2020
Editada: Life is Wonderful
el 20 de Nov. de 2020
Life is Wonderful
el 21 de Nov. de 2020
Editada: Life is Wonderful
el 21 de Nov. de 2020
Categorías
Más información sobre Get Started with GPU Coder en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
