Path: news.mathworks.com!not-for-mail
From: "Martin " <macin@o2.pl>
Newsgroups: comp.soft-sys.matlab
Subject: Code optimization
Date: Thu, 23 Aug 2007 10:15:38 +0000 (UTC)
Organization: University of Birmingham
Lines: 30
Message-ID: <fajmoa$3nv$1@fred.mathworks.com>
Reply-To: "Martin " <macin@o2.pl>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1187864138 3839 172.30.248.37 (23 Aug 2007 10:15:38 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 23 Aug 2007 10:15:38 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 823478
Xref: news.mathworks.com comp.soft-sys.matlab:425160



Dear All,

I am struggling with my algorithm to work fast enough. Is
there any possibility to make this work faster?
Thank you very much for any advice:

function o = netoutput( vw, in, n )
% n - number of hidden neurons
% vw - weights string
% in - input neurons values

sIn = max( size( in, 2 ) ); % number of input neurons

Y = in';
k = 1;
j = 1;

for i = sIn : sIn + n - 1

tmp = sum(vw( k : k + i -1 )'.*Y );
k = k + i;

tmp = exp( 2 * tmp );
tmp = ( tmp - 1 )./ ( tmp + 1 );

Y( i+1, 1 ) = tmp;
j = j + 1;
end

o = Y( end, 1 );