From: Oz on
Hi!

I'm new to Matlab.
I'm using Matlab R2007a and Java. I defined a function using newff. I built java class file for that function using Matlab Java Builder. The function runs correctly from Matlab command line. But when I use it Java code it generates below error message and throws an exception. Why I'm getting this message:

??? Error using ==> network.subsasgn at 489
"performFcn" cannot be set to non-existing function "mse".

Error in ==> newff at 147

Error in ==> contextf at 5

com.mathworks.toolbox.javabuilder.MWException: Error using ==> network.subsasgn
at 489
"performFcn" cannot be set to non-existing function "mse".Error in =>contextf.m
at 5
From: Greg Heath on
On Jul 27, 3:13 pm, "Oz " <ozgun_yil...(a)ttmail.com> wrote:
> Hi!
>
> I'm new to Matlab.
> I'm using Matlab R2007a and Java. I defined a function using newff. I built java class file for that function using Matlab Java Builder. The function runs correctly from Matlab command line. But when I use it Java code it generates below error message and throws an exception. Why I'm getting this message:
>
> ??? Error using ==> network.subsasgn at 489
> "performFcn" cannot be set to non-existing function "mse".
>
> Error in ==> newff at 147
>
> Error in ==> contextf at 5
>
> com.mathworks.toolbox.javabuilder.MWException: Error using ==> network.subsasgn
> at 489
> "performFcn" cannot be set to non-existing function "mse".Error in =>contextf.m
> at 5

Apparently the NN Toolbox function mse is not recognized.

Hope that helps.

Greg
From: Steven_Lord on


"Oz " <ozgun_yilmaz(a)ttmail.com> wrote in message
news:i2nb47$lvc$1(a)fred.mathworks.com...
> Hi!
>
> I'm new to Matlab.
> I'm using Matlab R2007a and Java. I defined a function using newff. I
> built java class file for that function using Matlab Java Builder. The
> function runs correctly from Matlab command line. But when I use it Java
> code it generates below error message and throws an exception. Why I'm
> getting this message:

MATLAB Compiler (and by extension MATLAB Builder JA) do not support
deploying files that create new networks; they support deploying files that
_use_ already created networks.

http://www.mathworks.com/products/compiler/compiler_support.html

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Oz on
Ok, thanks. Now as a solution I first run below file from matlab:

context.m:
---------------------------------------------------------------------------------------------------------
input=csvread('input.txt');
target=csvread('output.txt');
netContext=newff(minmax(input),[8,1],{'tansig','purelin'},'trainlm');
netContext.trainParam.epochs = 1000;

[netContext,tr]=train(netContext,input,target);
save ('c:\netContext.mat', 'netContext')
------------------------------------------------------------------------------------------

Then I'm calling contextf below from my java code:

contextf.m:
--------------------------------------------------------------------------------------
function [sonuc]=contextf(in1,in2,in3,in4,in5,in6,in7,in8)

load ('C:\netContext.mat','netContext');
net=network(netContext); %Without this line matlab gives an error from java
sonuc=sim(net,[in1;in2;in3;in4;in5;in6;in7;in8]);
----------------------------------------------------------------------------------------

Is this right?
It does what I want. If I erase "net=network(netContext);" line, I can use contextf from matlab's command line without any error, but from java It gives an error. So i added this line to convert nn object to network.
I don't know Why does it give an error and throws exception from java but it runs fine from matlab? Peculiar!