How to sum the results given by loop
- From: "Shanmukha Moturu" <Shanmukharao.Moturu@xxxxxxxxx>
- Date: Tue, 24 Jun 2008 15:50:19 +0000 (UTC)
Hi
i am have writen simple program as shown below
Z = input('Enter number of charge particles');
L = input('Enter the length of a plate');
H = input('Enter the distances between two plates');
X = input('Enter the value of x axis for point P');
Y = input('Enter the value of y axis for point p');
for n = 0:(Z-1)
N = (2*n)+1;
r = (N*L*1e-2)/(2*Z);
rn = sqrt((Y*1e-6)^2+(r^2));
P=1/rn
Vp = (1/6.672e-12)*P2;
end
Vp
when i run this program i found that Vp is giving nth
value of P.
But, what i am looking for is add all the P values
i mean P = (1/r1+1/r2+....+1/rn)
so that the sum of this value will be multipled by
(1/6.672e-12)
I tryed to do this by defing p2 = p2+P, but i'm unbale to
get it.
how i do this kind of problem
.
- Follow-Ups:
- Re: How to sum the results given by loop
- From: Rune Allnor
- Re: How to sum the results given by loop
- Prev by Date: Constant Data (matrix) Save inside "parfor" Loop
- Next by Date: Re: Setting uicontrol callbacks outside of the main gui .m file
- Previous by thread: Constant Data (matrix) Save inside "parfor" Loop
- Next by thread: Re: How to sum the results given by loop
- Index(es):
Relevant Pages
|