import numpy as np
A=np.ones((2,3,4),dtype=int)
B=np.zeros((2,3,4),dtype=int)
#Data_xpol_1 = Data_xpol[0,:,:] – Data_co[0,:,:]
#Data_xpol Data_co長度為(2,6,101)
C=A[0,:,:] – B[0,:,:]
print(“A:”,A)
print(type(A))
print(len(A))
print(“B:”,B)
print(type(B))
print(len(B))
print(“C:”,C)
print(type(C))
print(len(C))
A,B是三維陣列
C=A[0,:,:] – B[0,:,:]
C的第一個維度消失了
降為2維陣列
import numpy as np
A=np.ones((2,3,4),dtype=int)
B=np.zeros((2,3,4),dtype=int)
A0=[ [1,2,3,4],\
[5,6,7,8], \
[9,10,11,12] ]
A1=[ [5,6,7,8],\
[5,6,7,8], \
[5,6,7,8] ]
A[0] = A0
A[1] = A1
“””
#Data_xpol_1 =
Data_xpol[0,:,:] – Data_co[0,:,:]
#Data_xpol Data_co長度為(2,6,101)
“””
C=A[0,:,:] – B[0,:,:]
print(“A:”,A)
print(type(A))
print(len(A))
print(“B:”,B)
print(type(B))
print(len(B))
print(“C:”,C)
print(type(C))
print(len(C))
A,B都有兩個3×4的2D陣列
index為0,1
C=A[0,:,:] – B[0,:,:]
效果為A[0]-B[0]
A[0] B[0]都是3×4的2D array
直接寫C=A[0] – B[0]
比較快又易懂
C=A[0,:,:] – B[0,:,:]
這樣寫的原因
可能是要讓viewer知道
A, B是3D array
近期留言