This post is a continuation of Introduction to Freemat :
Freemat is an excellent graphing tool, and with a little bit of electrical theory under our belts we can use it to predict the state of a circuit element at some point in the future. As a consequence of Maxwell's Laws, the solution to the state of a circuit which contains resistors, inductors and capacitors is takes the form of a differential equation.
Frequently, the voltage may resemble one of the following graphs if the circuit is not continuously driven by some input voltage.
In this case, it is clear that the voltage is oscillating and decaying at the same time. This appears to be an exponential with both real and imaginary parts. (if that is unclear please review Euler's Formula) and we can model it very efficiently in Freemat.
The script that outputs those three waveforms is as follows:
========================================================
%ploting complex exponentials
pptau = 100 %data points per time constant
real = 1; % the real coefficient
imag = 3; % the complex coefficient
tc = 5; % how many time constants to plot
s=(1:pptau*tc)/pptau; %a normalised axis
for i0 = 1:pptau*tc
e1(i0) = exp(-(real+imag*j)*i0/pptau);
e2(i0) = exp(-(real+imag*1.5*j)*i0/pptau);
e3(i0) = exp(-(real+imag*2*j)*i0/pptau);
end
plot(s,e1)
hold on
plot(s,e2)
plot(s,e3)
hold off
=========================================================
Assignment 1 :
A)
Use Freemat to model the output of two exponential decay circuits with time constants of 100ms and 200ms. Which one reaches steady state sooner?
The original script can be modified in some simple ways to achieve this result.
I will allow you to figure that part out for yourself, but the results can be seen here.
it is clear that the blue signal (time constant of 100ms) decays to the steady state condition first.
B)
The circuit is redesigned so the output is now 2(1-e^(-t/tau)), plot their outputs.
Once again, a few changes to the original script make easy work of this assignment.
Assignment 2:
A)
Find the numerical and analytical solution to the addition of the following two sinusoids:
3sin(2t+10degrees)
5cos(2t-30degrees)
Analytical solution 7.3sin(2t+41.66degrees)
plot of numerical and analytical solutions in freemat, NOTE: the accuracy of the analytical solution was so close to the numerical that it was impossible to distinguish the two sinusoids from each other. This plot shows one with a vertical offset of .3 units in order to prove that both solutions are being graphed.
Assignment 3:
A) Let A1 = 3+2j, A2 = -1+4j, B = 2-2j. Find (A1*B)/A2 by hand, and then using freemat.
Here is the proof of solving it by hand:
And here is the result in Freemat:
The answers are sufficiently similar.
B)
Develop a sketch in freemat which can convert from rectangular to polar and from polar to rectangular.
try example 1 and show the results in 2 forms.
C)
Redo part A and B for the equation D = (A1+B) * A2