Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

emlc mxArray issue

2 views (last 30 days)
Jeremiah
Jeremiah on 28 Jul 2011
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi,
I'm fairly new to Matlab Embedded Coder and i have issue regarding the mxArray. The error shown is
??Subscripting into an mxArray is not supported.
And i have the piece of code here:-
Ab1 = (xmax + rand(S1,R).*(xmin-xmax))./2;%will transfer into 5 x 9 matrix
Ab2 = (ymax + rand(S2,S1).*(ymin-ymax))./2;%will transfer into 5 x 9 matrix
b1=(a + (b-a) *rand(S1,1)); % Weights between Input and Hidden Neurons
b2=(a + (b-a) *rand(S2,1)); % Weights between Hidden and Output Neurons
n1=Ab1*Ab;
A1 = logsig(n1);
n2=Ab2*A1;
%Line with error specified
Cc = n2(:,i)* Ab(i,:); %find a way to get it supported by emlc because n2(:,1)and Ab(i,:)can be broken up in C
g = (Cc./beta) .* exp(-fitin);
c = logsig(n2)+ Cc + g;
C = c - 1;%C is the matrix containing the clones generated from this calculation
e=C-T;
error =0.5* mean(mean(e.*e));
The error message seem to be located in the Cc equation where the n2(:,i)* Ab(i,:) is described. Seems to me that the emlc doesn't support this piece of function.

Answers (2)

Rick Rosson
Rick Rosson on 28 Jul 2011
  1. Could you please fix the indentation of the code in your question to make it a bit easier to read?
  2. I do not see where you have defined or pre-allocated the variable Ab, which you are referencing in the expression on assigned to the variable Cc. Did you define or pre-allocate Ab in some earlier code that you are not showing here?
  3. If not, please try to pre-allocate or initialize Ab before you use it in an expression.
HTH.
Rick

Mike Hosea
Mike Hosea on 28 Jul 2011
The LOGSIG function is not supported for code generation, so you must have declared it extrinsic. Read the documentation about declaring things extrinsic. There should be some examples there that show you how to make it work in Simulink or in MATLAB if you are building a mex file (you need to pre-define the output type of each call). Nothing will make an extrinsic function work for an embedded target--that's a contradiction. That is to say, if you are generating code for it, it's not extrinsic. If it's extrinsic, you aren't generating code for it (just using the MATLAB that is running on your computer). -- Mike

This question is closed.

Community Treasure Hunt

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

Start Hunting!