Using emlc to generate C code - function within a function problem
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello fellow Matlab users,
Ive been trying to convert a massive code from matlab to c and implement it for real time signal processing on a DSP processor.
So far ive been succesfull and emlc is an amazing function! The problem i have reached now is that I need to compile a code that has the function "butter" inside (gives out butterworth filter coefficients.)
The problem is that the compilation report complains about butter`s input arguments are not constant.
To make things a bit more clear:
C_generating_script.m => Function_1.m => butter.m
Now my question is:
How can I define/declare the inputs of the butter function as constants which is within another function and allow it to compile?
0 Kommentare
Akzeptierte Antwort
Kaustubha Govind
am 24 Feb. 2011
Have you tried specifying constant inputs using emlcoder.egc: http://www.mathworks.com/help/toolbox/eml/ug/bq2wkmb-47.html#brl11_g-1
2 Kommentare
Kaustubha Govind
am 25 Feb. 2011
Could you give a simple example of what you are doing? I tried the following, and it compiled without using emlcoder.egc:
-------- mytest.m ----------
function [b, a] = mytest
%#codegen
n = 4; Wn = 0.5;
a = zeros(1,5);
b = zeros(1,5);
[b a] = subfun(n,Wn);
-------- subfun.m ----------
function [b a] = subfun(n, Wn)
%#codegen
[b a] = butter(n, Wn);
Weitere Antworten (3)
Andreas Prokopiou
am 27 Feb. 2011
1 Kommentar
Kaustubha Govind
am 28 Feb. 2011
You should use:
emlc -eg {emlcoder.egc(dt),fasterdt,CF_of_channel,audiotimeofblock } MAP_ParamGen.m -c -T RTW -report
To specify that 'dt' as a constant, since this determines one of the inputs to butter.
Andreas Prokopiou
am 1 Mär. 2011
2 Kommentare
Kaustubha Govind
am 1 Mär. 2011
Did you try by specifying all relevant inputs: dt and OMEfilters as constant inputs using emlcoder.egc?
Fred Smith
am 14 Jul. 2011
Try using eml.unroll on the for-loop. That will cause the loop to be unrolled in the generated code.
This may or may not be acceptable depending on how many iterations the loop has. If it is not acceptable then you need a butter function that supports non-constant inputs. That capability is not available today.
If that is what you need, could you explain your use case and we'll create an enhancement request to add this capability to the product.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Reporting and Database Access finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!