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?
--
> "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?
--