Contoh Program dengan Fungsi, Numpy, Scipy dan Matplotlib

import numpy as np
import scipy as sc

t = np.linspace(0, 10, 1000)
A = 120
k1 = 0.3
k2 = 0.4
k3 = 0.5

def fungsi_exp(k,t):
N = A*np.exp(k*t)
return N

Pop1 = fungsi_exp(k1,t)
Pop2 = fungsi_exp(k2,t)
Pop3 = fungsi_exp(k3,t)

import matplotlib.pyplot as plt
plt.figure(1)
plt.subplot()
plt.plot(t, Pop1, 'r-', label='k1')
plt.plot(t, Pop2, 'k--',label='k2')
plt.plot(t, Pop3, 'bo-', label='k3')
plt.legend(loc='upper left', shadow=False, frameon=False)
plt.show()

Terakhir diubah: Friday, 31 July 2020, 08:49