Non-constant expression or empty matrix .This expression must be constant because its value determines the size or class of some expression

function I am going to convert from .m to .c file using matlab coder while doing it so i am getting error in
this line of below shown code i.e fieldName = char(theFields(match))% case-sensitive field name
code :

回答 (1 件)

theParam = model.(fieldName);
That struct potentially have a different type for each field, so the type of theParam is not fixed, and so cannot be compiled for.
If you were to initialize theParam to a fixed size and type then possibly you could get further.

3 件のコメント

theParam = zeros(1,1,'double');
like this ?
Yes, that might work, possibly.
Jeevan Kulal
Jeevan Kulal 2022 年 2 月 1 日
編集済み: Jeevan Kulal 2022 年 2 月 2 日
function theParam = getParamESC(paramName,temp,model)
theParam = zeros(1,1,"double");
.....further code
i have initialized as shown above, but still getting the same error.

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

カテゴリ

ヘルプ センター および File ExchangeMATLAB Coder についてさらに検索

質問済み:

2022 年 2 月 1 日

編集済み:

2022 年 2 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by