Sign in

username:

password:



Not a member?

Search matlab



Search tips

Subscribe to matlab



matlab by Keywords

Atanh | Autocorrelation | Bandpass Filter | C++ | Conv | Database | Deconv | Excel | FFT | Filter | Filtering | FIR | Fourier Transfrom | FSK | Gaussian Noise | Haykin | IFFT | Image | Java | LFSR | LMS | LPC | MEX | OFDM | QPSK | Radix | Random | Sampling | Segmentation | Simulink | Visual Basic | Waveform | Wavelet

Ads

Discussion Groups

Discussion Groups | Matlab DSP | algorithm implementation

Technical discussion about Matlab and issues related to Digital Signal Processing.

  

Post a new Thread

algorithm implementation - stromhau - Apr 24 7:30:12 2008



Hi, did an attempt to implement the algorithm in section 4, in this
paper :www.stromhaug.no/text.pdf. Its the continuous dynamic
programming algorithm.
This is a none optimized version, but i have my doubt its acting
correctly. I would be happy if anyone could check my code and help me
out here. 

code :

function mini=cdp(ref, stream);

clear P;

tau=1;
mini=inf;
P=zeros(numel(ref),numel(stream));

P(:,1)=inf;
P(:,2)=inf;

for t=1:numel(stream),

    while(tau<numel(ref)+1)
        if (tau==1)
            P(1,t+2)=3*abs(stream(t)-ref(1));
        end
        
        if (tau==2)
            if(t==1)
             P(2,t+2)=
min(P(1,t+1)+3*abs(stream(t)-ref(2)),P(1,t+2)+3*abs(stream(t)-ref(2)));
            
            else
           
temp=min(P(1,t)+2*abs(stream(t-1)-ref(2))+abs(stream(t)-ref(2)),P(1,t+1)+3*abs(stream(t)-ref(2)
));
            P(2,t+2)= min(temp,P(1,t+2)+3*abs(stream(t)-ref(2))); 
            end
        end
        
        if(tau>2)
            if(t==1)
             P(tau,t+2)=
min(P(tau-1,t+1)+3*abs(stream(t)-ref(tau)),P(tau-2,t+1)+3*abs(stream(t)-ref(tau-1))+3*abs(strea
m(t)-ref(tau)));

            else
           
temp=min(P(tau-1,t)+2*abs(stream(t-1)-ref(tau))+abs(stream(t)-ref(tau)),P(tau-1,t+1)+3*abs(stre
am(t)-ref(tau)));
            P(tau,t+2)=
min(temp,P(tau-2,t+1)+3*abs(stream(t)-ref(tau-1))+3*abs(stream(t)-ref(tau)));

            end
        end
           tau=tau+1;
    end

    if((1/3*(tau-1))*P(tau-1,t+2)<mini)
        mini=(1/3*(tau-1))*P(tau-1,t+2);
    end
    p(t)=(1/3*(tau-1))*P(tau-1,t+2);
    
    tau=1;    
    
end

plot(p)



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )