simulink error:Class mismatch for variable 'exist'. Expected 'logical', Actual 'double'.

I get a error in a MATLAB function block
coder.extrinsic('exist');
N=1296;
if exist('w_1','var')
W1=w_1;
else
W1=zeros(N,1);
end

回答 (1 件)

chengxuan yu
chengxuan yu 2018 年 4 月 1 日
編集済み: Walter Roberson 2018 年 4 月 1 日
Because 'exist' return a double value and 'if' need to follow a logical value.
you can modify the code like this:
if isequal(exist('w_1','var'),1)
W1=w_1;
else
W1=zeros(N,1);
end

カテゴリ

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

質問済み:

2016 年 5 月 3 日

編集済み:

2018 年 4 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by