攝影或3C

Python三維陣列 import numpy as np ; A = np.ones((2,3,4),dtype=int) ; B = np.zeros((2,3,4),dtype=int)

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

儲蓄保險王

儲蓄險是板主最喜愛的儲蓄工具,最喜愛的投資理財工具則是ETF,最喜愛的省錢工具則是信用卡