Why do I get a found an mxArray error pointing to a variable that has a value from a function declared as coder.extrinsic?

Why do I get the error "Expected either a logical, char, int, fi, single, or double. Found an mxArray. MxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may only be used on the right-hand side of assignments and as arguments to extrinsic functions." for 'index= sum(cummu <= randm) +1;'
Sample code:
coder.extrinsic('get_param');
x = get_param(<modelname/block>,'Value');
y  = x + 5;

 采纳的回答

You need to explicitly mention the type for the variable that is receiving values from a function declared as coder.extrinsic. If not, MATLAB will return value of type mxArray. 
Sample code's answer:
coder.extrinsic('get_param');
x = double(0);
x = get_param(<modelname/block>,'Value');
y  = x + 5;

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Vehicle Dynamics Blockset 的更多信息

产品

版本

R2014b

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by