Last active
October 10, 2017 17:35
-
-
Save mdaddysman/63c223c42eb73a086b0b0ef563bf7143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tic | |
filename = 'Simulated1'; | |
ntraj = 1000; | |
maxlength = 3000; | |
H = round( random('unif',0.1,0.9,[ntraj,1]) .* 1000 ) ./ 1000; %longer decimals appear to give problems | |
lengths = random('unid',maxlength-1,[ntraj,1]) + 1; | |
logD = random('norm',0,0.5,[ntraj,1]); | |
D = 2.^logD; | |
points = zeros(sum(lengths),4); %x,y,frame,traj number | |
s = 1; | |
wh = waitbar(0,'Starting...'); | |
for m=1:ntraj | |
if H(m) > 0.475 && H(m) < 0.525 %H near 0.5 but not quite give errors | |
H(m) = 0.5; | |
end | |
temp = D(m).*wfbm(H(m),maxlength); %points of less than 100 give an error. Just subsample. | |
points(s:s+lengths(m)-1,1) = temp(1:lengths(m)); | |
temp = D(m).*wfbm(H(m),maxlength); | |
points(s:s+lengths(m)-1,2) = temp(1:lengths(m)); | |
points(s:s+lengths(m)-1,3) = 1:lengths(m); | |
points(s:s+lengths(m)-1,4) = m.*ones(lengths(m),1); | |
s = s+lengths(m); | |
waitbar(m/ntraj,wh,['Trajectory: ' num2str(m) ' of ' num2str(ntraj)]); | |
end | |
save([filename '.mat'],'H','lengths','logD','D','points'); | |
close(wh); | |
toc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My blog post describing the code snippet.