I want to write this code with 1 for loop and if statement........................................................................................................................................................................................................................................................................................................................................................... ........................................................................................................................................................................How do I do this?.......................................................................................................................
import numpy as np
import math
nlayerL = 1.5 # These are some variable
nlayerH = 2.4
nsub = 1.56028
lamda = 500e-9
twopi = 2*math.pi
for i in range(0,101): # First loop
laythic = i
sigmalayer = (twopi*laythic*1e-9*nlayerL)/lamda
m1 = np.array([[math.cos(sigmalayer),(1j/nlayerL)*math.sin(sigmalayer)],
[(1j*nlayerL)*math.sin(sigmalayer),math.cos(sigmalayer)]])
b = m1[0][0] + m1[0][1]*nsub
c = m1[1][0] + m1[1][1]*nsub
y = c/b
print(y.real)
for k in range(0,101): #* Second loop
laythic = k
sigmalayer = (twopi*laythic*1e-9*nlayerH)/lamda
m2 = np.array([[math.cos(sigmalayer),(1j/nlayerH)*math.sin(sigmalayer)],
[(1j*nlayerH)*math.sin(sigmalayer),math.cos(sigmalayer)]])
m3 = np.matmul(m2,m1)
b = m3[0][0] + m3[0][1]*nsub
c = m3[1][0] + m3[1][1]*nsub
y = c/b
print(y.real)
I want to write this code with 1 for loop and if statement.......................................................................................................................................................................................................................................................................................................................................................... ...................................................................................................................................................................................How do I do this?.......................................................................................................................
Aucun commentaire:
Enregistrer un commentaire