circuit class

Circuit object

Syntax

cktobj = circuit
cktobj = circuit(cktname)

Description

Use circuit class to build a circuit object which can contain elements like resistor, capacitor, and inductor.

cktobj = circuit creates a circuit object cktobj with default name unnamed.

cktobj = circuit(cktname) creates a circuit object cktobj with name of cktname.

Properties

expand all

NameObject Namestring

Read-only string that contains the name of the circuit. Default name is unnamed. Two circuit elements attached together or belonging to the same circuit cannot have the same name

ElementNamesElement namescell vector of strings.

Cell vector contains the names of the elements added to the circuit. The possible elements here are resistor, capacitor, inductor, and circuit.

TerminalsNames of terminalscell vector of strings.

The cell vector contains the names of the terminals of the circuit object. Use setterminals or setports function to define the terminals. The terminals of the circuit are only displayed once it is defined.

PortsNames of portscell vector of strings.

Cell vector contains the names of the ports of the circuit object. Use setports function to define the ports. The ports of the circuit are only displayed once it is defined.

NodesCircuit nodesvector of integers.

List of nodes already defined in the circuit object. These nodes are created when a new element is attached to the circuit.

ParentPathfull path of circuit object.string

Full path of the parent circuit to which child circuit belongs. This path appears only once the child circuit is added to the parent circuit.

ParentNodesParent Circuit nodesvector of integers.

The term ParentNodes describes the nodes of parent circuit to which the child circuit is connected. This vector of integers is the same length as the Terminals property. This property appears only after the child circuit is added to the parent circuit.

Examples

Create , Add Elements, and Setterminals of a Circuit

Create a circuit called new_circuit1.

hckt1 = circuit('new_circuit1');

Add a resistor and capacitor to the circuit.

CAP1= add(hckt1,[1 2],capacitor(3e-9));
RES1 = add(hckt1,[2 3],resistor(100));

Set the terminals of the circuit and display the result.

setterminals(hckt1,[1 3]);
disp(hckt1)

The resulting output is as follows:

circuit: Circuit element

    ElementNames: {'C'  'R'}
           Nodes: [1 2 3]
            Name: 'new_circuit1'
       Terminals: {'t1'  't2'}

Create a Circuit with Two Elements in Parallel

Add a capacitor and inductor in parallel to a circuit.

hckt2 = circuit('new_circuit2');
CAP2 = add(hckt2,[1 2],capacitor(1e-12));
IND2 = add(hckt2,[1 2],inductor(1e-9));
disp(hckt2)
 circuit: Circuit element

    ElementNames: {'C'  'L'}
           Nodes: [1 2]
            Name: 'new_circuit2'
Was this topic helpful?