Main Content

add

Insert circuit element or circuit object into circuit

Description

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. If elem is a Touchstone file name or s-parameters object, an nport object is created from input and added to cktobj.

example

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

example

elem_out = add(_____) returns the inserted circuit element elem_out as an output. Specify any of the input argument combinations in the previous syntaxes.

example

Examples

collapse all

Create a resistor, and add it to a circuit.

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

     Resistance: 50
           Name: 'R'
      Terminals: {'p'  'n'}
    ParentNodes: [1 2]
     ParentPath: 'new_circuit1'
disp(hckt1)
  circuit: Circuit element

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

Create a capacitor.

hC2 = capacitor(1e-10)
hC2 = 
  capacitor: Capacitor element

    Capacitance: 1.0000e-10
           Name: 'C'
      Terminals: {'p'  'n'}

disp(hC2)
  capacitor: Capacitor element

    Capacitance: 1.0000e-10
           Name: 'C'
      Terminals: {'p'  'n'}

Connect terminal n of the capacitor to node 3 and terminal p of the capacitor to node 4.

hckt2 = circuit('new_circuit2');
add(hckt2,[3 4],hC2,{'n' 'p'})
disp(hckt2)
  circuit: Circuit element

    ElementNames: {'C'}
        Elements: [1x1 capacitor]
           Nodes: [3 4]
            Name: 'new_circuit2'

Create a circuit.

hckt3 = circuit('new_circuit3')
hckt3 = 
  circuit: Circuit element

    ElementNames: {}
           Nodes: []
            Name: 'new_circuit3'

Insert an inductor into the circuit using the add function.

hL3 = add(hckt3,[100 200],inductor(1e-9));

Display the circuit element.

disp(hckt3)
  circuit: Circuit element

    ElementNames: {'L'}
        Elements: [1x1 inductor]
           Nodes: [100 200]
            Name: 'new_circuit3'

Display the inserted circuit element.

disp(hL3)
  inductor: Inductor element

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

Create circuit 1 and set the terminals using the setterminals functions.

hckt1 = circuit('circuit_new1');
add(hckt1,[1 2], resistor(100));
setterminals(hckt1, [1 2]);
disp(hckt1);
  circuit: Circuit element

    ElementNames: {'R'}
        Elements: [1x1 resistor]
           Nodes: [1 2]
            Name: 'circuit_new1'
       Terminals: {'t1'  't2'}

Create circuit 2 and set the terminals.

hckt2 = circuit('circuit_new2');
add(hckt2, [3 4], capacitor(1.5e-9));
setterminals(hckt2, [3 4]);
disp(hckt2);
  circuit: Circuit element

    ElementNames: {'C'}
        Elements: [1x1 capacitor]
           Nodes: [3 4]
            Name: 'circuit_new2'
       Terminals: {'t1'  't2'}

Add the two circuits.

add(hckt1, [2 4], hckt2);
disp(hckt2)
  circuit: Circuit element

    ElementNames: {'C'}
        Elements: [1x1 capacitor]
           Nodes: [3 4]
            Name: 'circuit_new2'
       Terminals: {'t1'  't2'}
     ParentNodes: [2 4]
      ParentPath: 'circuit_new1'
disp(hckt1)
  circuit: Circuit element

    ElementNames: {'R'  'circuit_new2'}
        Elements: [1x2 rf.internal.circuit.Element]
           Nodes: [1 2 4]
            Name: 'circuit_new1'
       Terminals: {'t1'  't2'}

Input Arguments

collapse all

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

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.

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

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

Output Arguments

collapse all

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 elements.

Version History

Introduced in R2013b

expand all