Problem Compiling function subset with EMLC
Ältere Kommentare anzeigen
Hello everybody,
I have problems with the emlc compiler. I want to generate c code for a lowpass filter for a real time DSP. I followed the Matlab tutorial and created a M-file with the code:
function [ output ] = Lowpassfilter ( input ) %#emlc
n = 5; Wn = 0.5;
[b a] = butter (n, Wn, input);
output = filter(b, a, input);
%input comes from the ADC and is int32 in the DSP program
%the ADC samples at 48kHz and provides new data through the bus every sample time
I have tried the command lines: emlc Lowpassfilter and some derivations (-c -t RTW). The error message is: "Function 'butter' imlicitly resolved in the Matlab workspace..." How can i use matlab subset functions, when compiling them with emlc? Do i need to add -eg declarations for the DSP input and how do i do that?
Akzeptierte Antwort
Weitere Antworten (1)
Kaustubha Govind
am 8 Mär. 2011
1 Stimme
As explained in the entry for butter in the Embedded MATLAB Function Library Reference, you need to provide constant inputs to the function. In your function, 'input' is a non-const variable. To specify it as constant, you can use something like:
emlc mytest.m -eg {emlcoder.egc('high')}
1 Kommentar
Bruce
am 17 Mär. 2011
Kategorien
Mehr zu Get Started with DSP System Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!