I'm using Matlab Coder to convert this code to C++:
fs = 50;
[b,a] = butter(3,0.5/(fs/2),'high');
...
% Other code using fs
Then, I get this error: "All inputs must be constant".
If I do: [b,a] = butter(3,0.5/(50/2),'high');
, it works.
I found this post: Constants and Matlab Coder
So I tried:
fs = 50;
[b,a] = coder.const(@butter,3,0.5/(fs/2),'high');
But it still reports the same error. How can I fix this?
Define Class Properties with Constant Values
In ConstInput.m
classdef ConstInput
properties (Constant)
fs = 50;
end
end
Then rename fs
as ConstInput.fs
. (Unfortunately, Shift+Enter
does not work. Maybe this links helps about changing variable names.)