'function [ index] = SoftMax( Q )
Temperature = 0.5; terms = Q/Temperature;
Prob = softmax (terms);
cummu = cumsum (Prob);
randm = rand();
index= sum(cummu <= randm) +1;'
Dear MATLAB community,
I am using this code on MATLAB Function block in Simulink. 'Q' is an array which made 'cummu' an array too. Running this function at MATLAB command windows doesn't have problems, but running in Simulink returns "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;'
I have also tried
'for i = 1:numel(Q) if(randm >= cump(i)) action = action +1; end end'
but it returns "Subscripting into an mxArray is not supported. ... ... cummu (i)... ..."
I am stuck on this, please help. Thank you!