it is being difficult plotting the graph for Capacitance vs Distance D..please provide me a suitable solution to plot the graph

%USING THE METHOD OF MOMENT,
% THIS PROGRAM DETERMINES THE CAPACITANCE OF A
% PARALLEL-PLATE CAPACITOR CONSISTING OF TWO CONDUCTING
% PLATES, EACH OF DIMENSION AA x BB, SEPARATED BY A
% DISTANCE D, AND MAINTAINED AT 1 VOLT AND -1 VOLT
% ONE PLATE IS LOCATED ON THE Z = 0 PLANE WHILE THE OTHER
% IS LOCATED ON THE Z=D PLANE
% ALL DIMENSIONS ARE IN S.I. UNITS
% N IS THE NUMBER IS SUBSECTIONS INTO WHICH EACH PLATE IS
%DIVIDED
% FIRST, SPECIFY THE PARAMETERS
ER = 1.0;
EO = 8.8541e-12;
AA = 1.0;
BB = 1.0;
D = 1.0;
N = 9;
NT = 2*N;
M = sqrt(N);
DX = AA/M;
DY = BB/M;
DL = DX;
% SECOND, CALCULATE THE ELEMENTS OF THE COEFFICIENT
% MATRIX A
K = 0;
for Kl=1:2
for K2=1:M
for K3=1:M
K = K + 1;
X(K) = DX*(K2 - 0.5);
Y(K) = DY*(K3 - 0.5);
end
end
end
for K1=1:N
Z(K1) = 0.0;
Z(K1+N) = D;
end
for I=1:NT
for J=1:NT
if(I==J)
A(I,J) = DL*0.8814/(pi*EO);
else
R = sqrt( (X(I)-X(J))^2 + ( Y(I)-Y(J) )^2 + ( Z(I)-Z(J) )^2 ) ;
A(I,J) = DL^2/(4.*pi*EO*R);
end
end
end
% NOW DETERMINE THE MATRIX OF CONSTANT VECTOR B
for K=1:N
B(K) = 1.0;
B(K+N) = -1.0;
end
% INVERT A AND CALCULATE RHO CONSISTING
% THE UNKNOWN ELEMENTS
% ALSO CALCULATE THE TOTAL CHARGE Q AND CAPACITANCE C
F = inv(A);
RHO = F* (B');
SUM = 0.0;
for I=1:N
SUM = SUM + RHO(I);
end
Q = SUM*(DL^2) ;
VO = 2.0;
C = abs(Q)/VO;
Please provide a suitable solution to plot the graph Capacitance vs Distance

6 Comments

yes..just have a problem how to plot the graph Capacitance vs Distance..could you help me on this ??
As far as I can tell both distance and capacitance are scalars, not vectors. Am I correct? If so, what do you want plot exactly?
with increase in distance .....i wanted to see how the capacitance changes...because after some point of time there will be fringing effect whoch will cause disruption..so just wanted to check that

Sign in to comment.

Answers (1)

you have to measure each time the capacitance with varying d, there is peak at d=0.1, is this reasonable ? :
%USING THE METHOD OF MOMENT,
% THIS PROGRAM DETERMINES THE CAPACITANCE OF A
% PARALLEL-PLATE CAPACITOR CONSISTING OF TWO CONDUCTING
% PLATES, EACH OF DIMENSION AA x BB, SEPARATED BY A
% DISTANCE D, AND MAINTAINED AT 1 VOLT AND -1 VOLT
% ONE PLATE IS LOCATED ON THE Z = 0 PLANE WHILE THE OTHER
% IS LOCATED ON THE Z=D PLANE
% ALL DIMENSIONS ARE IN S.I. UNITS
% N IS THE NUMBER IS SUBSECTIONS INTO WHICH EACH PLATE IS
%DIVIDED
% FIRST, SPECIFY THE PARAMETERS
ER = 1.0;
EO = 8.8541e-12;
AA = 1.0;
BB = 1.0;
N = 9;
NT = 2*N;
M = sqrt(N);
DX = AA/M;
DY = BB/M;
DL = DX;
D=0:0.001:1;
for n=1:length(D);
% SECOND, CALCULATE THE ELEMENTS OF THE COEFFICIENT
% MATRIX A
K = 0;
for Kl=1:2
for K2=1:M
for K3=1:M
K = K + 1;
X(K) = DX*(K2 - 0.5);
Y(K) = DY*(K3 - 0.5);
end
end
end
for K1=1:N
Z(K1) = 0.0;
Z(K1+N) = D(n);
end
for I=1:NT
for J=1:NT
if(I==J)
A(I,J) = DL*0.8814/(pi*EO);
else
R = sqrt( (X(I)-X(J))^2 + ( Y(I)-Y(J) )^2 + ( Z(I)-Z(J) )^2 ) ;
A(I,J) = DL^2/(4.*pi*EO*R);
end
end
end
% NOW DETERMINE THE MATRIX OF CONSTANT VECTOR B
for K=1:N
B(K) = 1.0;
B(K+N) = -1.0;
end
% INVERT A AND CALCULATE RHO CONSISTING
% THE UNKNOWN ELEMENTS
% ALSO CALCULATE THE TOTAL CHARGE Q AND CAPACITANCE C
F = inv(A);
RHO = F* (B');
SUM = 0.0;
for I=1:N
SUM = SUM + RHO(I);
end
Q = SUM*(DL^2) ;
VO = 2.0;
C(n) = abs(Q)/VO;
end
figure, plot(D,C);

6 Comments

?? Error using ==> plot Vectors must be the same lengths.
Error in ==> Capacitance at 70 figure, plot(D,C); this is the error when I try to change the value of d ....??
means if I am changing the value of d , suppose from D= [0:0.01:5] then the error shows is
?? Error using ==> plot Vectors must be the same lengths.
Error in ==> Capacitance at 70 figure, plot(D,C)
so any solution for this ?
I Am facing anew problem...the problem is i need to change the N (NUMBER IS SUBSECTIONS INTO WHICH EACH PLATE IS DIVIDED) IF am changing the values it is throwing this error :
let i put N=20
?? Attempted to access X(33); index out of bounds because numel(X)=32.
Error in ==> Capacitance at 45 R = sqrt( (X(I)-X(J))^2 + ( Y(I)-Y(J) )^2 + ( Z(I)-Z(J) )^2 ) ;
any help on this ...because if i change N its showing error as mentioned above..so please help me...
check the loop
for Kl=1:2
for K2=1:M
for K3=1:M
K = K + 1;
X(K) = DX*(K2 - 0.5);
Y(K) = DY*(K3 - 0.5);
end
end
end
The variables X and Y seems to be dependent on sqrt(N), which will cause trouble with N = 20. It would be more stable to give M a value and define N as
N = M^2;

Sign in to comment.

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Products

Asked:

on 2 Feb 2014

Edited:

on 3 Feb 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!