Untitled
unknown
plain_text
4 months ago
796 B
1
Indexable
import numpy as np import matplotlib.pyplot as plt data = np.loadtxt('frogmuscleT1.txt') v = data[:,1] T1 = data[:,0] plt.plot(v,T1,'o',markersize=4, color='firebrick',label='Frog muscle data points') ln_T1 = np.log(T1) ln_v = np.log(v) n = len(ln_v) sum_x = np.sum(ln_v) sum_y = np.sum(ln_T1) sum_xy = np.sum(ln_v * ln_T1) sum_x2 = np.sum(ln_v**2) B = (n * sum_xy - sum_x * sum_y) / (n * sum_x2 - sum_x**2) ln_A = (sum_y - B * sum_x) / n A = np.exp(ln_A) print(f"Fitted equation: T_1 = {A:.2f} * v^{B:.2f}") A = 208.30 B = 0.38 v_fit = np.linspace(1, 62, 100) T1_fit = A * v_fit**B plt.plot(v_fit, T1_fit, label=f'Fit: $T_1 = {A:.2f} \, v^{{{B:.2f}}}$', color='cornflowerblue') plt.xlabel('Frequency, MHz') plt.ylabel('T1, ms') plt.legend(fontsize=12) plt.savefig("frogmuscleT1.png")
Editor is loading...
Leave a Comment