jeudi 29 octobre 2015

Random path in MATLAB

I have a simple random path code:

    while t <= T 
    p=rand(1,N); 
    for i=1:N 
    if p(i) < p_l
        pos(i)=pos(i)-delta_x; 
    elseif p(i) < (1-p_r)
        pos(i)=pos(i); 
    else
        pos(i)=pos(i)+delta_x; 
    end
    end
    t=t+tau; 
    end

But I need a help with a more complicated random path project, it's about a need for two functions that need for the generation of random trajectories. The first one calculates the cumulative density functions for both change of segment length and change in direction and stores it for later use (and analysis). The second one then takes the number of segments from the measured path and generates a random trajectory by using the cdfs generated by the first function. This step should be fast as that is used repeatedly many times to generate a high number of random paths; ranging from -1 to 1. A typical path consists of 4 - 50 segments. First xy values representing the first node, the next pair the next node and so forth. The direct connection between a node to the next represents a segment. Each segment has a specific length and a specific directional aberration relative to the preceding segment.
For a measured path, both change of segment lengths and change of direction show a specific distribution that can be expressed as a cumulative density function. I think this could be done with a built in cd function.

Any suggestions?

Thanks! Stepphan




Aucun commentaire:

Enregistrer un commentaire