1
votes

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 conssole 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);
1
How are you calling the MATLAB function from the C# code? It seems that the parameter x1 is not being set correctly.Bill Cheatham
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]);Baran

1 Answers

2
votes

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;