user_move

PURPOSE ^

moves the mobiles

SYNOPSIS ^

function mob = user_move(par,mob,t)

DESCRIPTION ^

 moves the mobiles

  INPUT
   par        general parameters structure
   mob        mobiles structure before movement
   t          iteration

  OUTPUT
   mob        mobiles structure after movement


 $Id: user_move.m,v 1.15 2004/07/19 06:52:15 dalai Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % moves the mobiles
0002 %
0003 %  INPUT
0004 %   par        general parameters structure
0005 %   mob        mobiles structure before movement
0006 %   t          iteration
0007 %
0008 %  OUTPUT
0009 %   mob        mobiles structure after movement
0010 %
0011 %
0012 % $Id: user_move.m,v 1.15 2004/07/19 06:52:15 dalai Exp $
0013 
0014 function mob = user_move(par,mob,t)
0015 
0016 rand('state',sum(100*clock));
0017 randn('state',sum(100*clock));
0018 
0019 switch (par.model)
0020 
0021 case 1
0022     for m = 1:par.mob
0023         mob(m).v(t+1) = real(mob(m).v(1)*(1+mob(m).vstate*randn));
0024         mob(m).xy(t+1) = user_wrapper(mob(m).xy(t) + mob(m).v(t+1),par);
0025     end
0026 
0027 case 2
0028     for m=1:par.mob
0029     % simplified notations
0030     xy(m) = mob(m).xy(t);
0031     v(m) = mob(m).v(t);
0032 
0033     % users on N-S streets
0034     if (mod(real(xy(m)-par.build_width/2),par.build_width)==0)&(mod(imag(xy(m)-i*par.build_width/2),par.build_width)~=0)
0035         v(m)=i*sign(imag(v(m)))*norm(mob(m).v(1)*(1+mob(m).vstate*irandn));
0036         % users at crosspoint
0037         if (abs(rem(imag(xy(m)-i*par.build_width/2),par.build_width))<5)
0038             xy(m) = (round(real(xy(m)-par.build_width/2)/par.build_width) + i*(round(imag(xy(m)-i*par.build_width/2)/par.build_width)))*par.build_width + (1+i)*par.build_width/2; 
0039             v(m) = v(m)*exp(i*pi/2*fix(8*(rand-0.5)/2));
0040         end
0041     end
0042     
0043     % users on W-E streets
0044     if (mod(real(xy(m)-par.build_width/2),par.build_width)~=0)&(mod(imag(xy(m)-i*par.build_width/2),par.build_width)==0)
0045         v(m)=sign(real(v(m)))*norm(mob(m).v(1)*(1+mob(m).vstate*irandn));
0046         %users at crosspoint
0047         if (abs(rem(real(xy(m)-par.build_width/2),par.build_width))<5)
0048             xy(m) = (round(real(xy(m)-par.build_width/2)/par.build_width) + i*(round(imag(xy(m)-i*par.build_width/2)/par.build_width)))*par.build_width + (1+i)*+par.build_width/2;
0049             v(m) = v(m)*exp(i*pi/2*fix(8*(rand-0.5)/2));
0050         end
0051     end
0052 
0053     mob(m).v(t+1) = v(m);
0054     mob(m).xy(t+1) = user_wrapper(xy(m) + v(m),par);
0055     end
0056 
0057 case 3
0058     for m = 1:par.mob
0059         mob(m).xy(t+1) = user_wrapper(mob(m).xy(t) + mob(m).v(t),par);
0060         mob(m).v(t+1) = norm(mob(m).v(1))*(exp(i*angle(mob(m).v(t))) + mob(m).vstate*irandn);
0061     end    
0062 
0063 end

Generated on Sun 15-Aug-2004 22:13:10 by m2html © 2003