capacitor class

Capacitor object

Syntax

cobj = capacitor(cvalue)
cobj = capacitor(cvalue,cname)

Description

Use the capacitor class to create a capacitor object that you can add to an existing circuit.

cobj = capacitor(cvalue) creates a capacitor object, cobj, with a capacitance of cvalue and default name, C. cvalue must be a non-negative scalar.

cobj = capacitor(cvalue,cname) creates a capacitor object, cobj, with a capacitance of cvalue and name cname. cname must be a string.

Properties

expand all

Capacitanceobject valuescalar

Capacitance, in farads, of the capacitor object.

Nameobject namestring

Read-only string that contains the name of the capacitor object. Default name is C. Two elements in the same circuit cannot have the same name.

Terminalsnames of terminals.cell vector

Read-only cell vector that contains the names of the two terminals of the capacitor object. These names are always p and n.

ParentPathfull path of capacitor.string

Full path of the circuit to which the capacitor object belongs. This path appears only after the capacitor is added to the circuit.

ParentNodesCircuit nodesvector of integers.

The nodes in the parent circuit that are connected to the capacitor terminals. This property is appears only after the capacitor is added to a circuit.

Examples

Create and Display a Capacitor

hC1 = capacitor(2e-6);
disp(hC1)
 capacitor: Capacitor element

    Capacitance: 2.0000e-06
           Name: 'C'
      Terminals: {'p'  'n'}

Create and Extract S-parameters of a Capacitor

hC2 = capacitor(2e-6,'C2uf');
hcktcap2 = circuit('example2');
add(hcktcap2,[1 2],hC2)
setports(hcktcap2, [1 0],[2 0])
freq = linspace(1e3,2e3,100);
S = sparameters(hcktcap2,freq);
disp(S)
 sparameters: S-parameters object

       NumPorts: 2
    Frequencies: [100x1 double]
     Parameters: [2x2x100 double]
      Impedance: 50

  rfparam(obj,i,j) returns S-parameter Sij

Add a Capacitor to a Circuit to Display ParentPath and ParentNodes

hC3 = capacitor(3e-6,'C3uf');
hckt3 = circuit('example3');
add(hckt3,[1 2],hC3)
setports(hckt3, [1 0],[2 0])
disp(hC3)
  capacitor: Capacitor element

    Capacitance: 3.0000e-06
           Name: 'C3uf'
      Terminals: {'p'  'n'}
    ParentNodes: [1 2]
     ParentPath: 'example3'
Was this topic helpful?