Understanding MATLAB code for creating a wireless sensor network -


i have following matlab code used aid in creating wireless sensor network:

for i=1:n     s(i).xb=rand*0.5*xm;     s(i).yb=rand*0.5*ym;     s(i).e=eo;     s(i).g=0;     s(i).type='n';     s(i).id=i;     s(i).d=dist(bs.x,bs.y,s(i).xb,s(i).yb);     s(i).etx=eelec*k+eamp*k*s(i).d^2;     plot(s(i).xb,s(i).yb,'o');     end plot(bs.x,bs.y,'rx'); 

in program, why there dots in code? example, s(i).xb=rand*0.5*xm;. can explain me?

in code, s array of structures. each structure contain following member variables:

  • xb
  • yb
  • e
  • g
  • type
  • id
  • d
  • etx

doing s(i).xb = rand*0.5*xm; first create structure within array s @ location i contains single member xb. assigned value of rand*0.5*xm. rest of statements keep appending more variables same structure @ location i in array.

after, if wish access member variable @ location i array s, still s(i).xb, or s(i).yb, etc.

essentially, can think of s having array of elements each element has 8 fields within element. you'd access field using ..


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -