Introduction to Simulink with Engineering Applicatioins, Second Edition

An S-Function example is presented in Subsection 11.18, Chapter 11, Page 11 49. In Subsections 20.11.1 and 20.11.2 below, we present two more examples.
For semiconductor diodes, the empirical equations describing the temperature coefficient dV F/dT in mV/ C as a function of forward current I F in mA are
where, for this example,
I ff = final value of forward current
I fv = variable value of forward current
We begin with the user-defined m-file below which we type in the Editor Window and we save it as diode.m
<font color="0000ff">function</font> dx=diode(t,x,Ifv)<font color="ff0000">%</font><font color="ff0000">% Model for gold-doped and non-gold-doped diodes</font><font color="ff0000">%</font>Vf1 = x(1); <font color="ff0000">% Gold-doped diode forward voltage, volts</font>Vf2 = x(2); <font color="ff0000">% Non-gold-doped diode forward voltage, volts</font>Iff = 100; <font color="ff0000">% Iff = final value in of forward current in mA</font>dVf1 = 0.6*log10(Iff)-1.92;dVf2 = 0.33*log10(Iff-Ifv)-1.66; <font color="ff0000">% Ifv = variable value of forward current in mA</font>dx = [dVf1;dVf2];
To test this function for correctness, on MATLAB's Command Window we type and execute the command
[t,x,lfw]=ode45(@diode, [0 10],[1;10],[ ], 50)<span class="beginpage"> pagenum="20-66"><a name="2075"></a><a name="IDX-20-66"></a></span>
where the vector [0 10] specifies the start and the end of the simulation time, the vector [1 ;10] specifies an initial value column vector, the null vector [ ] can be used for other options, and the input value is set to 50.
Next, using the Editor Window we write the m-file below and...