Main Content

setports

Set ports of circuit object

Description

setports(cktobj,nodepairs) defines the node_pairs in an N-port cktobj using nodepairs argument. This syntax then assigns the ports default names. It also defines the terminals of a cktobj, taking the terminal names from the port names. If any of the node pairs do not exist, setports creates it.

example

setports(cktobj,nodepairs,portnames) defines the node_pairs in an N-port cktobj as ports using nodepairs argument. After defining the ports, this syntax names them using portnames. The length of the portnames must equal to the number of node_pairs in the circuit.

example

Examples

collapse all

Create a 1-port circuit using setports.

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

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

Create a circuit and define two ports. Name the ports in and out.

 hckt2 = circuit('example_circuit2');
 add(hckt2,[2 3],resistor(50))
 add(hckt2,[3 1],capacitor(1e-9))
 setports(hckt2,[2 1],[3 1],{'in' 'out'})
 disp(hckt2)
  circuit: Circuit element

    ElementNames: {'R'  'C'}
        Elements: [1x2 rf.internal.circuit.RLC]
           Nodes: [1 2 3]
            Name: 'example_circuit2'

Input Arguments

collapse all

Circuit object for which the ports are defined, specified as scalar handle objects.

Node pairs of the circuit object, specified as vector of integers. The function uses this input argument to define the ports.

Names to name the ports defined for the circuit object, specified as character vector.

Version History

Introduced in R2013b