I'm trying to do a hierarchical RF circuit analysis, by subclassing circuit, giving it terminals, then adding it to another circuit. It allows me to do the add, but when I try to analyse, I get the following error cascade
Error using ==
Cannot call method 'eq' because one or more inputs of class 'circuit' are heterogeneous and 'eq' is
not sealed. For more details please see the method dispatching rules for heterogeneous arrays.
Error in rf.circuit.flattener/getglobalnode (line 139)
Error in rf.circuit.flattener/makenodeobjects (line 132)
Error in rf.circuit.flattener/buildcircuitlevel (line 80)
Error in rf.circuit.flattener/buildcircuitlevel (line 86)
Error in rf.circuit.flattener/flattencircuit (line 36)
Error in rf.circuit.pcircuit/calc_sparams (line 366)
Error in sparameters (line 180)
inputs{1} = calc_sparams(inputs{:});
Unfortunately, I haven't a clue what this means, as I'm new to 2014a, OO in Matlab, and the RF Toolbox.
When I create a circuit in a script by adding components, adding terminals, and then add that into another circuit in the same script, it will analyse as sparameters without error.
When I subclass circuit and add components, add ports, and analyse its sparameters, that works as well.
Is it the case that I can't add an object subclassed from circuit into another circuit, even if it has terminals? I'm suspicious that it is complaining about ==, and a subclass of circuit is not a circuit object, though it does have a superset of its properties and methods, so should work where a circuit would (I'm coming from Python, where duck-typing is the rule).
Can I nest circuits like this?
For the record, this is my classdef
classdef three_term < circuit
properties
cap
res
ind
end
methods
function s = three_term(name)
s = s@circuit(name);
s.cap = capacitor(10e-12, 'cap_name');
s.ind = inductor(2e-9, 'ind_name');
s.res = resistor(1000, 'res_name');
add(s, [1,2], s.ind);
add(s, [2,0], s.cap);
add(s, [1,0], s.res);
setterminals(s, [0 1 2]);
end
end
end