1

I have a simple function about neural network. This function gets a matrix, loads mat file and runs a neural network function with this parameter. In matlab console this is working perfectly. But in C# gives error;

... MWMCR::EvaluateFunction error ... 
Subscript indices must either be real positive integers or logicals.
Error in => neural.m at line 4.

... Matlab M-code Stack Trace ...
    at file c:\xxxxxxxxxxxx\NeuralClass\neural.m, name neural, line 4.

This is my simple function;

function  result=neural(x1)
load('fonksiyon.mat', 'net')
x1=x1';
result= net(x1);
2
  • How are you calling the MATLAB function from the C# code? It seems that the parameter x1 is not being set correctly. Commented Apr 4, 2012 at 23:29
  • I also tried this but still no working function result=neural() func = load('fonksiyon.mat', 'net'); result= func.net([0.1; 0.1; 0.2; 0.1; 0.5; 0.4; 0.7; 0.1]); Commented Apr 4, 2012 at 23:37

1 Answer 1

2

Sim is not working with .net assembly. This helped me;

function  result=neural(P)
load('c:\function.mat', 'net');

IW = net.IW{1};
b1 = net.b{1};
LW = net.LW{2};
b2 = net.b{2};

P=P';

y1 = satlin (IW * P + b1 );
y2 = tansig (LW * y1 + b2 );

result= y2;
Sign up to request clarification or add additional context in comments.

Comments

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.