error with coder.type​('constant​',value)

13 ビュー (過去 30 日間)
Jane Jean
Jane Jean 2013 年 7 月 31 日
When I I get this error when I declare variable 'a' and 'b' as constants and take max(a,b):
Undefined function 'max' for input arguments of type 'coder.Constant'
Is there a way to get round this since 'a' and 'b' are really constants in my code?
Thank you!
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 31 日
How did you declare them as a constant?

サインインしてコメントする。

採用された回答

Ryan Livingston
Ryan Livingston 2013 年 8 月 1 日
Did you put the line:
a = coder.type('constant',value);
in the code on which you are calling CODEGEN? The function coder.type is intended to be used as an input argument to CODEGEN and not in the M file for which you are generating code.
If you have:
function y = foo(a,b)
if a < 10
y = b;
else
y = 2*b;
end
and 'a' is constant, say 10, then you could do:
t = coder.Constant(10);
codegen foo -args {t, single(0)}
to specify that the top-level input, 'a' is constant.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by