In message <eec4f48.1@WebX.raydaftYaTP>, Cy Todd
<cytodd@technimation.com> writes
>I need to create Simulink models of a resistor, capacitor and
>inductor so that I can concatenate these models into any arbitrary
>network and run a simulation of the network.
>
>
>As I see it, the basic problem is how to model a bidirectional
>component with only input and output ports. For instance, if a
>resistor model had 2 inputs corresponding to the voltage at each end
>of the resistor, one could define a current output = the input
>difference divided by the R value. There is no way I can see of
>concatenating this model with others to form a resistor network for
>simulation.
>
>
>MatLab/Simulink Tech Support said they have no information on how to
>do this and couldn't help me. The Simpower toolbox didn't look very
>useful either.
>
>
>As far as writing an Sfunction, I don't know how to structure the
>code soas to produce a bidirectional model that concatenates. Any
>suggestions?
This is an Octave (not Matlab/Simulink) example showing one way of
calculating network impedance which might be distantly related to what
you need. It assumes that the network can be reduced to an equivalent
complex impedance between two terminals.
%impedance of a simple network of RLC components
f=(10.^(0:.01:7)); % frequency range 1Hz to 10 MHz
jw=(2*pi*i).*f; % rad/sec
%component values
r1=10000; % ohm
r2=1000;
r3=5000;
l1=1e4; % henry
c1=1e7; % farad
%component impedances
zr1=r1; % resistor: Z = R
zr2=r2;
zr3=r3;
zl1=jw .* l1; % inductor: Z = jw .* L
zc1=1 ./ (jw .* c1); % capacitor: Z = 1 ./ (jw .* C)
function z=ser(z1,z2)
%impedances in series
z=z1.+z2;
end
function z=par(z1,z2)
%impedances in parallel
z=(z1.*z2)./(z1.+z2);
end
%network impedance
z=ser(par(zr1,ser(zr2,zl1)),par(zr3,zc1));
loglog(w,abs(z))
Hope this helps

Alan Linton
to reply change "alan@..." to "alan.linton@..."
