X-Received: by 10.180.20.239 with SMTP id q15mr5405354wie.7.1365608534986;
        Wed, 10 Apr 2013 08:42:14 -0700 (PDT)
Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!19no75752303wie.1!news-out.google.com!p18ni48895wiv.0!nntp.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Can this run any faster?
Date: Wed, 10 Apr 2013 10:42:15 -0500
Organization: Aioe.org NNTP Server
Lines: 34
Message-ID: <kk418i$anr$1@speranza.aioe.org>
References: <kk24q4$3j5$1@newscl01ah.mathworks.com> <kk2qqh$158$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: ZKBAJ1SlwxDSzSjObSya5Q.user.speranza.aioe.org
Mime-Version: 1.0
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
X-Notice: Filtered by postfilter v. 0.8.2
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Xref: news.mathworks.com comp.soft-sys.matlab:793172

On 4/9/2013 11:46 PM, Roger Stafford wrote:
> "Elnaz " <ebsadeghian@gmail.com> wrote in message
> <kk24q4$3j5$1@newscl01ah.mathworks.com>...
...

>> ...Is there anyway to make this run faster?
>>
>> a=zeros(16,length);
>> a=a-inf;
>> a(1,1)=0; for i= 2:length
>> for j= 1:32
>> A = a(transitions(j,2),i);
>> B = a(transitions(j,1),i-1) + ug(j, i-1) + eg(j, i-1);
...

> You might try the following. (I am assuming 'ug' and 'eg' are always
> finite.)
>
> a=zeros(16,length); % <-- Don't use "length". It's the name of a matlab
> function
> a=a-inf;
> a(1,1)=0;
> t1 = transitions(j,1); %<-- Avoid needless indexing in the loops
> t2 = transitions(j,2);
...

Roger, these need to be

t1 = transitions(:,1); %<-- Avoid needless [2D] indexing in the loops
t2 = transitions(:,2);

don't they?

--