[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Average Magnitude Differential Function - implementation
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: Average Magnitude Differential Function - implementation |
Date: |
Wed, 5 May 2010 17:06:37 -0500 |
On 5 May 2010 14:29, jacek grabowski <address@hidden> wrote:
> N=length(w);
> for k=1:N
> suma=0;
> for n=1:N-k
> suma=suma+abs(w(k)-w(k+n)); % 2 001 000 times for N=2001
> endfor
> amdf(k)=suma;
> endfor
You're basically forming all the pairwise difference of the vector,
and then doing a cumsum in reverse. Here's one way to replace the
quoted code.
[a,b] = meshgrid(w,w);
amdf = sum(tril(abs(a-b))));
HTH,
- Jordi G. H.