Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Simulink resistor, capacitor, inductor models

Subject: Simulink resistor, capacitor, inductor models

From: Cy Todd

Date: 6 Oct, 2003 15:08:15

Message: 1 of 3

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 S-function, I don't know how to structure the
code soas to produce a bidirectional model that concatenates. Any
suggestions?

Subject: Simulink resistor, capacitor, inductor models

From: Wolfgang Hammer

Date: 7 Oct, 2003 09:49:04

Message: 2 of 3

Cy Todd wrote:

> Thanks for the reply Stuart. Having played with the Simulink demo for
> awhile, I was aware of this toolset, but it seemed aimed at electric
> power generation and transmission. Anyway, my management elected not
> to get it [...]

For simulating electrical circuits with Simulink, you may also want to
evaluate the add-on PLECS which has a graphical schematic editor. A limited
student is available for free and can be downloaded from

http://www.plexim.com/downloads/

In this version, the number of inductors and capacitors is limited to a
total of four, however. (The number of resistors is unlimited.)

And there's yet another possibility: If your circuit consists only of linear
elements (i.e. RLC, sources and meters) and if you are not afraid of
netlists, you can also try the tool 'netlist2ss' available for free from
the same web-site. This Matlab function calculates the state-space matrices
for a linear electrical circuit. You can then use these matrices in the
'State-Space' block in Simulink.

> So the problem remains how to construct a model of resistors, caps
> and inductors from the basic Simulink toolbox.

There's no easy way to do this. The time you'll spend on trying it is
definitely going to be more expensive than the license for the appropriate
toolbox (unless you just want to model one circuit and never change it ...)

Regards,
Wolfgang

Subject: Simulink resistor, capacitor, inductor models

From: Alan Linton

Date: 7 Oct, 2003 19:26:42

Message: 3 of 3

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 S-function, 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=1e-4; % henry
c1=1e-7; % 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@..."

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us