Accelerating the pace of engineering and science

# Documentation Center

• Trial Software
• Product Updates

# setterminals

Set terminals of circuit object

## Syntax

• setterminals(cktobj,cktnodes) example
• setterminals(cktobj,cktnodes,termnames) example

## Description

example

setterminals(cktobj,cktnodes) defines the nodes in a cktobj as terminals using cktnodes. It then gives the terminals default names.

example

setterminals(cktobj,cktnodes,termnames) defines the nodes in a cktobj as terminals cktnodes. It then names the terminals using termnames. cktnodes and termnames must be same length.

## Examples

### Create a Circuit and Define Its Nodes as Terminals

Create a circuit names new_circuit1 and a add a resistor and capacitor to it. Set the terminals of this circuit.

```hcktnode1 = circuit('new_circuit1');
add(hcktnode1,[1 2],resistor(50))
add(hcktnode1,[2 3],capacitor(1e-9))
setterminals(hcktnode1,[1 3])
disp(hcktnode1)
```
```   circuit: Circuit element

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

### Create a Circuit and Define Its Nodes as Terminals Using Names

Create a circuit and add three resistors to it. Set terminals of the circuit by using (a, b, c) as termnames.

```hcktnode2 = circuit('new_circuit2');
add(hcktnode2,[1 2],resistor(50))
add(hcktnode2,[1 3],resistor(50))
add(hcktnode2,[1 4],resistor(50))
setterminals(hcktnode2,[2 3 4],{'a' 'b' 'c'})
disp(hcktnode2)
```
```    circuit: Circuit element

ElementNames: {'R'  'R_1'  'R_2'}
Nodes: [1 2 3 4]
Name: 'new_circuit2'
Terminals: {'a'  'b'  'c'}
```

### 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 the 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 for which the terminals are defined, specified as a scalar handle object.

### cktnodes — Circuit nodesvector of integers

Circuit nodes, used by the function to define the terminals of the circuit, specified as a vector of integers.

### termnames — Names cell vector of strings

Names, used to identify the terminals defined for the circuit object, specified as cell vector of strings.

## See Also

Was this topic helpful?