Skip to content

Instantly share code, notes, and snippets.

@tobin
Last active December 14, 2015 07:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobin/5049621 to your computer and use it in GitHub Desktop.
Save tobin/5049621 to your computer and use it in GitHub Desktop.
Experimenting with Numerical Python
% Matlab code to plot a cavity resonance
F = 10; % Finesse
f = linspace(-0.5, 1.5, 201);
P = 1./(1 + (2/pi) * F^2 * sin(pi*f).^2);
plot(f, P);
xlabel('free spectral ranges');
ylabel('power buildup');
#!/usr/bin/python
# Python code to plot a cavity resonance
import numpy as numpy
F = 10
f = numpy.linspace(-0.5, 1.5, 201)
P = 1 / (1 + (2/numpy.pi) * F**2 * numpy.sin(numpy.pi * f) ** 2)
import matplotlib.pyplot as plt
plt.plot(f, P)
plt.xlabel("free spectral ranges")
plt.ylabel("power buildup")
plt.show()
#!/usr/bin/python
from numpy import *
from matplotlib.pyplot import *
F = 10
f = linspace(-0.5, 1.5, 201)
P = 1/ (1 + (2/pi) * F**2 * sin(pi*f)**2)
plot(f, P)
xlabel("free spectral ranges")
ylabel("power buildup")
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment