I can't use FIS parameters for any calculation or even compare in Simulink model

1 view (last 30 days)
I have designed a model which is simplified in this picture:
in my Matlab Function I have read a FIS file.
function out = fcn(current_state)
coder.extrinsic('readfis','evalfis');
fismat=readfis('sugeno3');
[output, IRR, ORR, ARR]= evalfis(current_state,fismat);
find(ARR>0)
out = 1;
the "evalfis" function just works fine and evaluates the results. the problem is when i want to check or use one of the output parameters like "ARR". for example, I debugged and saw that ARR has values. but when i use this code or something similar to that:
find(ARR>0)
I get this 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.
Function 'MATLAB Function' (#41.181.184), line 6, column 10:
"ARR"
Launch diagnostic report.

Accepted Answer

Marie Behzadi
Marie Behzadi on 28 Aug 2015
I'd like to share the answer that I've found. The problem has been solved by initialization of output parameters to define their type. If "N" is the number of Rules in FIS, "I" is the number of input variables in FIS, and "O" is the number of output parameters, then the outputs should define like this:
output=0;
IRR=zeros(N,I);
ORR=zeros(N,O);
ARR=zeros(N,O);
where you exactly know the "N", "I", "O" (or at least restrict their upper bound). This is because Simulink needs to know the exact type of variables at the beginning of Matlab Function (which is not necessary in Matlab).

More Answers (0)

Categories

Find more on Deployment in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!