Clear Filters
Clear Filters

Is there anybody to help me fix the error and convert mxArray to double?

27 views (last 30 days)
I am trying to implement the m-file into Matlab Function in Simulink. It needs to run some code conversion. Since "care()" function is not in the main library of this code converter, I have added coder.extrinsic('care'). Now when I run the Simulink it shows me the error as in the attached figure.
coder.extrinsic('care')
[~,~,G0] = care(hA, hB2, eye(4), eye(1), zeros(4,1), E);
KK=G0;
bA=hA-hB2*KK;
Now in my case bA(4x4 matrix), hB2(4x1 double), KK(1x4 mxArray). In fact after multiplication bA*hB2 should return 4x4 matrix. The problem is that KK should be double in order to work. How can I fix this issue of converting mxArray to double?
The code runs ok on m-file, but when I try to implement it on Simulink, it doesn't. I plan later to convert it to C++ code.

Accepted Answer

James Tursa
James Tursa on 29 Aug 2017
What happens if you add this prior to the "care" call:
G0 = zeros(1,4);
  2 Comments
Drill Be
Drill Be on 31 Aug 2017
Thank you, it works. But now I faced another similar issue with mxArray when I want to multiply two state space systems. For instance G12*KK, it shows the same error mxArray. Both are State-space model with 3 outputs, 1 inputs, and 4 states.

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink 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!