Professional Documents
Culture Documents
3: SciLab
dy
.
dt
Numerically,
y(i)y(i1)
t(i)t(i1)
1
NDSU
3: SciLab
or
-->size(y)
301.
1.
-->dy = 0*y;
-->for i=2:300
-->
dy(i) = (y(i+1) - y(i-1)) / 0.02;
-->
end
-->plot(t,dy)
Note that differentiation amplifies the high-frequency terms. The 50 rad/sec term dominates the result.
The integral is
t
0 y dt y(i) dt
t
i=0
in SciLab
-->iY = 0*y;
-->for i=2:301
-->
iY(i) = iY(i-1) + y(i)*0.01;
-->
end
-->plot(t,iY)
Note that integration amplifies the low-frequency terms. The resulting signal is dominated by a ramp: the
integral of a constant is a ramp.
2
NDSU
3: SciLab
You can also use SciLab to solve for 2 equations and 2 unknowns. For example, when we get to diodes, we'll try
to solve the following two equations for V and I:
V=5I
V = 0.0526 ln (10 5 I + 1)
In SciLab
-->I = [0:0.01:5]';
-->V1 = 5-I;
-->V2 = 0.0526*log(1e5*I+1);
-->plot(V1,I,V2,I);
-->xlabel('Volts');
-->xgrid(5)
-->ylabel('mA');
The solution from the graph is where the two graphs interesect. You can also find this numerically.
Guess I.
Find V from equation 1 and 2
Find the difference in V. This gives a function of I whose solution is when f(I)=0.
Use a solver (such as Newton's method) to find I:
The results is (0.6825V, 4.3175mA)
G(s) =
-->f
-->w
-->j
-->s
-->G
=
=
=
=
=
5s
s 2 +5s+100
[0:0.01:10]';
2*%pi*f;
sqrt(-1);
j*w;
5*s ./ (s.^2 + 5*s + 100);
-->plot(f,abs(G))
-->xlabel('Hz');
-->ylabel('gain');
NDSU
3: SciLab
NDSU
3: SciLab
note: If you create a bunch of files, you can load them into Scilab one at a time. Save the environment. When
you restart Scilab, load the environment and all the functions that were in Scilab before are there again.
NDSU
3: SciLab
MultiSim
MultiSim is available on the cluster computers. It allows you to run nonlinear numerical simulations of circuits.
Typically, each homework set should include:
Analysis: Using simplifying approximations (such as the voltage across a diode is 0.7V and there is no
resistance), calculate values for resistors and compute what the currents and voltages should be.
Simulation: Using MultiSim, check your answers with a more complex (and more accurate, but still
impefect) tool
Hardware: Determine the actual currents, voltages etc. with real components.
All results should be similar - but slightly different due to the simplifying approximations used.
For example, determine the voltage at y(t) for x(t) being a 5Vp 1kHz sine wave with Multi-Sim.
R1
I0
+
x(t)
I1
I2
C
R2
y(t)
In MultiSim,
Add the components using the drop-down menu bars on the top
Connect components using click and drag
Add a multimeter or oscilloscope from the menu on the right
Click the on-off switch
For print-outs, reverse the image of the o-scope
The net result will look like the following:
NDSU
3: SciLab