1

Using matlab coder, I get Subscripting into an mxArray is not supported. error in the following function:

function net = mlpunpak(net, w)
% Check arguments for consistency
errstring = consist(net, 'mlp');
if ~isempty(errstring);
    error(errstring);
end
nin = net.nin;
nhidden = net.nhidden;
nout = net.nout;

mark1 = nin*nhidden;
net.w1 = reshape(w(1:mark1), nin, nhidden);
mark2 = mark1 + nhidden;
net.b1 = reshape(w(mark1 + 1: mark2), 1, nhidden);
mark3 = mark2 + nhidden*nout;
net.w2 = reshape(w(mark2 + 1: mark3), nhidden, nout);
mark4 = mark3 + nout;
net.b2 = reshape(w(mark3 + 1: mark4), 1, nout);'  

I tried different solutions that I could find on the net but none of them worked (like: using coder.extrinsic('reshape'), initializing net.w1 with zeros ....) Anyone has any idea how to fix this?

13
  • 1
    Can you provide your build script? It's possibly a problem with the declarations of the parameters. Commented May 8, 2015 at 3:06
  • 3
    Also, are you using 'extrinsic' in other places in your code? Could you provide the entire function? Commented May 8, 2015 at 5:38
  • 1
    As @Tony said, there is an extrinsic function call somewhere whose output is being indexed. The documentation describes how to convert mxArray values (i.e. the output of extrinsic calls) to known types like double or int32. This answer also describes the situation. Commented May 8, 2015 at 12:28
  • @Tony: I don't have any build script. How can I create, declare and add a build script to my project? Here is what I am trying to compile: The entry-point file contains a function with three inputs. I defined the type of input parameters in coder. Inside that function, I am calling other functions from a package that I got online (Netlab source code and the folder containing the package is added to matlab path) and those functions call other functions from the package. Commented May 8, 2015 at 18:56
  • As @lilbill39 notes, the mxArray type shows up from return values from functions declared extrinsic. The answer he cites will show you how to make sure those variables are properly typed so you can use them. Commented May 8, 2015 at 18:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.