MATLAB Simulation for Calculation of Series and Parallel Capacitor

18 visualizaciones (últimos 30 días)
here is my coding to calculate the capacitance of series and parallel capacitor. but, matlab not regonize the part of calculate the D and W on the coding. I wish anyone can help me to find out the errors found in this coding. Thank you
%%Simulation of Capacitance of Two Type of Capacitor
%The value of the dielectric, ε_r surface area, S and its
%dimension (w,d) will be ask during the start of the program code.
clear
clc
% Constant
eps0 = 8.854187817e-12;
% Ask User Input
%dielectric
%Er1 and Er2
prompt = 'Insert the value of dielectric,Er1';
Er1 = input(prompt)
prompt = 'Insert the value of dielectric,Er2';
Er2 = input(prompt)
%Calculation of Er1 and ER2 for series capacitor
disp('The Calculation of Er1 and ER2 for series capacitor');
Y = (Er1*Er2)/(Er1+Er2)
%Calculation of Er1 and ER2 for series capacitor
disp('The Calculation of Er1 and ER2 for parallel capacitor');
X = Er1+Er2
%insert S,d and w
disp('S = surface area');
disp ('d = dimension for series capacitor');
disp('w = dimension for parallel capacitor/n');
prompt = 'Insert the value of S';
S = input(prompt)
prompt = 'Insert the value of d';
d = input(prompt)
prompt = 'Insert the value of w';
w = input(prompt)
%calculation of capacitance for series capacitor
disp('The Calculation of Capacitance for Series Capacitor');
disp('C =((2*eps0*S)/d)*((Er1*Er2)/(Er1+Er2))');
disp('The answer is:\n');
C1 = (2*eps0*S)/d
%calculation of capacitance for parallel capacitor
disp('The Calculation of Capacitance for Parallel Capacitor');
disp('C =((eps0*S)/2w)*((Er1+Er2))');
disp('The answer is:');
C2 = (eps0*S)/(2*w)

Respuestas (1)

Rishabh Mishra
Rishabh Mishra el 7 de En. de 2021
Hi,
I tried reproducing the code you provided on my system and it is working without errors. You’ve mentioned that you are calculating the values ‘D’ & ‘W’. However, in the code, user is prompted to input the values ‘d’ & ‘w’. Please clarify on this aspect.
Below I have provided the code to solve this issue:
% define dielectric constant
eps0 = 8.854187817e-12;
% declare variables Er1 Er2 using symbolic math
syms Er1 Er2;
% declare variables s, d, w using symbolic math
syms S d w;
% Net Dielectric of Parallel combination
Y = (Er1*Er2)/(Er1+Er2);
% Net Dielectric of Series combination
X = Er1+Er2;
% Net Capacitance in Parallel combination
C2 = (eps0*X*S)/w;
% Net Capacitance in Series combination
C1 = (eps0*Y*S)/d;
% take inputs for Er1, Er2, S, D & W
Er1in = input('Enter value of Er1: ');
Er2in = input('Enter value of Er2: ');
Sin = input('Enter value of S: ');
Din = input('Enter value of D: ');
Win = input('Enter value of W: ');
% evaluate the series & parallel resistances
disp(subs(C1,[Er1 Er2 S d w],[Er1in Er2in Sin Din Win]));
disp(subs(C2,[Er1 Er2 S d w],[Er1in Er2in Sin Din Win]));
In the code above, I have used syms to declare symbolic variables. Function ‘subs’ is used to substitute the values of variables ‘Er1’, ‘Er2’, ‘S’, ‘d’, ‘w’ (obtained from the user) into expressions of ‘C1’ & ‘C2’.
Hope this helps.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by