Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: total energy of sensor nodes

$
0
0
dpb <none@non.net> wrote in message <ku41j9$lsi$1@speranza.aioe.org>...
> On 8/9/2013 6:46 PM, Philip wrote:
> > for j=1:1:10
> > distance=sqrt((S(j).xd-sink.x)^2 + (S(j).yd-sink.y)^2);
> > Etotal=PL*(ETX+Efs*(distance).^2);
> > sum(Etotal)
> > end
> >
> > please i want to find sum Etotal. i did it but the last Etotal generated
> > is display as sum of the total. ...
>
> Of course, you overwrite it every pass thru the loop...
>
> "The Matlab way"...
>
> E=PL*(ETX+Efs*dot(S.xd-sink.x,S.yd-sink.y)));
> Etotal=sum(E);
>
> --
> please the last E generated is showing as the total, please i want to find the sum of E generated (i.e 1 to 10).
for j=1:1:10
    distance=sqrt((S(j).xd-sink.x)^2 + (S(j).yd-sink.y)^2);
    E=PL*(ETX+Efs.*(sqrt((S(j).xd-sink.x)^2 + (S(j).yd-sink.y)^2)))
   end
Etotal=sum(E)
>

Viewing all articles
Browse latest Browse all 19628

Trending Articles