Trying to embed circuits in RF Toolbox, getting incomprehensible error cascade
Ältere Kommentare anzeigen
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
% creates 3 terminal test network
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);
% setports(s, [1,0], [2,0]);
setterminals(s, [0 1 2]);
end
end
end
Akzeptierte Antwort
Weitere Antworten (1)
Joe Wargo
am 10 Jun. 2014
Hey Neil,
I think for your use-case, you should not have to use OO design or create a new object type. A MATLAB function should work fine. Consider:
function newckt = three_term(name)
newckt = circuit(name);
newcap = capacitor(10e-12, 'cap_name');
newind = inductor(2e-9, 'ind_name');
newres = resistor(1000, 'res_name');
add(newckt,[1,2],newind)
add(newckt,[2,0],newcap)
add(newckt,[1,0],newres)
setterminals(newckt,[0 1 2])
Then you can create one or more of these at the command line:
>> tt1 = three_term('one');
>> tt2 = three_term('two');
Then, as a simple example, you can add these "sub-circuits" into a "parent-circuit":
>> parent = circuit;
>> add(parent,[0 1 2],tt1)
>> add(parent,[0 2 3],tt2)
Lastly, if you want the S-parameters of the parent circuit, you will need to define ports on the parent circuit, then use the sparameters function:
>> setports(parent,[1 0],[2 0])
>> freq = [1e9 2e9];
>> S = sparameters(parent,freq);
One last note: the node "0" is the global ground. Use it carefully when you have hierarchy in your system.
Hope that helps!
Joe
1 Kommentar
Neil
am 13 Jun. 2014
Kategorien
Mehr zu Data Import and Network Parameters finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!