Documentation Center

  • Trial Software
  • Product Updates

add

Insert circuit element or circuit object into circuit

Syntax

  • add(cktobj,cktnodes,elem) example
  • add(cktobj,cktnodes,elem,termorder) example

Description

example

add(cktobj,cktnodes,elem) inserts a circuit element elem into a circuit object cktobj. The terminals of the elem are attached to the nodes specified in cktnodes.

example

add(cktobj,cktnodes,elem,termorder) the terminals specified in termorder are attached to circuit nodes specified in cktnodes.

example

elem = add(_____) returns elem as an output.

Examples

Add an Element to a Circuit

Create a resistor, and add it to a circuit.

R1 = resistor(50);
cktres1 = circuit('new_circuit1');
add(cktres1,[1 2],R1)
disp(R1)
disp(cktres1)
 resistor: Resistor element

     Resistance: 50
           Name: 'R'
      Terminals: {'p'  'n'}
    ParentNodes: [1 2]
     ParentPath: 'new_circuit1'

  circuit: Circuit element

    ElementNames: {'R'}
           Nodes: [1 2]
            Name: 'new_circuit1'

Add an Element to Specific Nodes of a Circuit

Create a capacitor. Then, connect terminal n of the capacitor to node 3 and terminal p of the capacitor to node 4.

C1 = capacitor(1e-10);
cktcap1 = circuit('new_circuit2');
add(cktcap1,[3 4],C1,{'n' 'p'})
disp(C1)
disp(cktcap1)
 capacitor: Capacitor element

    Capacitance: 1.0000e-10
           Name: 'C'
      Terminals: {'p'  'n'}
    ParentNodes: [4 3]
     ParentPath: 'new_circuit2'

  circuit: Circuit element

    ElementNames: {'C'}
           Nodes: [3 4]
            Name: 'new_circuit2'

Create and Insert an Element into Circuit Using Add

Create a circuit and insert an inductor into it using the add function.

cktind1 = circuit('new_circuit3');
L1 = add(cktind1,[100 200],inductor(1e-9));
disp(L1)
disp(cktind1)
 inductor: Inductor element

     Inductance: 1.0000e-09
           Name: 'L'
      Terminals: {'p'  'n'}
    ParentNodes: [100 200]
     ParentPath: 'new_circuit3'

  circuit: Circuit element

    ElementNames: {'L'}
           Nodes: [100 200]
            Name: 'new_circuit3'

Add Two Circuits Together

Create two circuits. Set the terminals of the child circuit using the setterminals functions before adding it to the parent circuit. Display both circuits.

hcktadd1 = circuit('circuit_new1');
add(hcktadd1,[1 2], resistor(100));
setterminals(hcktadd1, [1 2]);
hcktadd2 = circuit('circuit_new2');
add(hcktadd2, [3 4], capacitor(1.5e-9));
setterminals(hcktadd2, [3 4]);
add(hcktadd1, [2 4], hcktadd2);
disp(hcktadd2)
disp(hcktadd1)
 circuit: Circuit element

    ElementNames: {'C'}
           Nodes: [3 4]
            Name: 'circuit_new2'
       Terminals: {'t1'  't2'}
     ParentNodes: [2 4]
      ParentPath: 'circuit_new1'

  circuit: Circuit element

    ElementNames: {'R'  'circuit_new2'}
           Nodes: [1 2 4]
            Name: 'circuit_new1'
       Terminals: {'t1'  't2'}

Input Arguments

expand all

cktobj — Circuit objectscalar handle object

Circuit object into which the circuit element is inserted, specified as scalar handle object. This circuit object can be a new circuit or an already existing circuit.

cktnodes — Circuit nodesvector of integers

Circuit nodes of the circuit object, specified as vector of integers. The function uses this input argument to attach the new element to the circuit.

elem — Circuit elementsscalar handle objects

Circuit elements that are inserted into the circuit object, specified as scalar handle objects. The element can be a resistor, capacitor, inductor or an entire circuit.

termorder — Element terminalsvector of strings

Element terminals, which are the same strings found in Terminals property of elem. These input arguments are specified as scalar handle objects. .

Output Arguments

expand all

elem — Circuit elementsscalar handle objects

Circuit elements, which are returned as scalar handle objects, after using the add function. The function uses any or all of the input arguments to create these circuit element.

See Also

| | |

Was this topic helpful?