I just want to plot the second loop 5 times, but I have a problem with the dimentions. I get this error message that says G and t dosent have the same dimention. G has 450 and t has 50 dimentions.When I set the plot in the second loop, I get that G has size 100 and t has size 50.
import mpmath as mp import numpy as np import matplotlib as plt import sympy L=[0.04980905361573844, 0.0208207352451072, 0.012368753716465475, 0.009117292529338674, 0.007461219338976698, 0.006510364609693688, 0.005899506135250773, 0.005485130537183343, 0.0051898472561455] Lc=[1.7509008762765992, 0.14986486457338544, 0.03453912303580302, 0.014622269851256788, 0.00831141421008418, 0.005660123321843252, 0.004287823173522503, 0.0034922189865254395, 0.0029879534061896186] beta = 0.25; G =  t=np.linspace(0.00000000000001,0.000001,50) for i in range(len(L)): j0 = L[i]; j1 = Lc[i]; def f(s): return s**(beta - 1)/(j0*s**beta + j1*sympy.gamma(beta + 1)) for j in range(0,50): G.append(mp.invertlaplace(f, t[j], method = 'dehoog', dps = 10, degree = 50)) plt.plot(t,G)
If you take a look at your
for loop, your not clearing your
G list between iterations. Your adding 50 more items to G each time it is run. This is why the dimensions aren’t what you are expecting.
You can try something like this.
import matplotlib.pyplot as plt import numpy as np L = [1, 2, 3, 4, 5] G =  solutions =  t = np.linspace(0.00000000000001,0.000001,50) for _ in range(len(L)): for time in t: G.append(time**2) solutions.append(G) G =  fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(5) ax1.plot(t, solutions) ax2.plot(t, solutions) ax3.plot(t, solutions) ax4.plot(t, solutions) ax5.plot(t, solutions) plt.show()