Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

function handle

15 views
Skip to first unread message

Ivana

unread,
Oct 3, 2008, 12:24:01 PM10/3/08
to
Hello,

I don't have so much experience in working with Matlab, so I hope that you could help with some details.

I downloaded a code from mathworks for training mlp nn using extended kalman filter.
<code>

function [theta,P,e]=nnekf(theta,P,x,y,Q,R)
%f=@(u)u;
%h=@(u)nn(u,x,size(y,1));
[theta,P]=ekf(f,theta,P,h,y(:),Q,R);
e=h(theta);

% The NN model. It can be modified for different NN structure.
function y=nn(theta,x,ny)
[nx,N]=size(x);
ns=numel(theta);
nh=(ns-ny)/(nx+ny+1);
W1=reshape(theta(1:nh*(nx+1)),nh,[]);
W2=reshape(theta(nh*(nx+1)+1:end),ny,[]);
y=W2(:,1:nh)*tanh(W1(:,1:nx)*x+W1(:,nx+ones(1,N)))+W2(:,nh+ones(1,N));
y=y(:);
</code>

My problem is that I'm using Matlab, version 6.5, so in first 2 lines I receive an error: "identifier" expected, "(" found.

How can I change it, so that it works in version 6.5?

I appreciate your help

Ivana

unread,
Oct 3, 2008, 2:08:02 PM10/3/08
to
Is it at all possible, or I should find Matlab 7 and work in it?

Ivana

unread,
Oct 4, 2008, 6:30:04 AM10/4/08
to
OMG, I just saw that I copied my code wrong. These first 2 lines aren't comments, they go:

f=@(u)u;
h=@(u)nn(u,x,size(y,1));

And there is where the error appears. Can somebody help me now?

Loren Shure

unread,
Oct 7, 2008, 11:55:52 AM10/7/08
to
In article <gc7gjc$79q$1...@fred.mathworks.com>, ivan...@gmail.com says...

Anonymous functions, which is what these statements create, are
available starting in MATLAB 7.

--
Loren
http://blogs.mathworks.com/loren

0 new messages