resistor class

Resistor object


robj = resistor(rvalue)
robj = resistor(rvalue,rname)


Use the resistor class to create a resistor object that you can add to an existing circuit.

robj = resistor(rvalue) creates a resistor object, robj, with a resistance of rvalue and default name, R. rvalue must be a numeric non-negative scalar.

robj = resistor(rvalue,rname) creates a resistor object, robj, with a resistance of rvalue and name rname. rname must be a string.


expand all

Resistanceobject valuescalar

Resistance, in ohms, of the resistor object.

Nameobject namestring

Read-only string that contains the name of the resistor object. Default name is R. Two elements in the same circuit cannot have the same name.

TerminalsNames of terminalscell vector

Read-only cell vector that contains the names of the two terminals of the resistor object. These names are always p and n.

ParentPathfull path of resistor.string

Full path of the circuit to which the resistor object belongs. This path appears once the resistor is added to the circuit.

ParentNodesCircuit nodesvector of integers.

The term ParentNodes describes the nodes in the parent circuit that are connected to the resistor terminals. This property appears only after the resistor is added to a circuit.


Create and Display a Resistor

hR1 = resistor(100);
 resistor: Resistor element

    Resistance: 100
          Name: 'R'
     Terminals: {'p'  'n'}

Create and Extract S-parameters of a Resistor

hR2 = resistor(50,'R50');
hcktres2 = circuit('example2');
add(hcktres2,[1 2],hR2)
setports(hcktres2, [1 0],[2 0])
freq = linspace(1e3,2e3,100);
S = sparameters(hcktres2,freq);
 sparameters: S-parameters object

       NumPorts: 2
    Frequencies: [100x1 double]
     Parameters: [2x2x100 double]
      Impedance: 50

  rfparam(obj,i,j) returns S-parameter Sij

Add a Resistor to a Circuit to Display ParentPath and ParentNodes

hR3 = resistor(150,'R150');
hckt3 = circuit('example3');
add(hckt3,[1 2],hR3)
setports(hckt3, [1 0],[2 0])
  resistor: Resistor element

     Resistance: 150
           Name: 'R150'
      Terminals: {'p'  'n'}
    ParentNodes: [1 2]
     ParentPath: 'example3'
Was this topic helpful?