Constants and Matlab Coder

Some functions require the input to be constant when launched in Matlab Coder. I want to find a way to declare input as a constant before input as an example for a problem situation:

function foo = subsubfunction(x,y) [B,A]=butter(1,x/y); 

This will return a "All inputs must be constant" error.

How to declare x and y as constants so that oil () becomes happy? I tried many solutions and unfortunately did not find anything really satisfying. If the coder.newtype('constant',x) command line operation was used, this would simplify everything.

+4
source share
1 answer

Use coder.const in the function, so the butter function knows that you are passing constant input. Documentation is available here .

  function foo = subsubfunction(x,y) [B,A]=coder.const(@butter,1,x/y); 

Note You cannot change the x/y value in the generated code. You can individually change x and y , but not the ratio of two numbers.

+2
source

Source: https://habr.com/ru/post/1398624/


All Articles