Inquire about how to expand an array in Python

Asked 2 years ago, Updated 2 years ago, 41 views

# matte wrap code; fm size 3*10*5 
a = zeros(3,10);
fm = [];
for kCh = 1:5
    fm[:,:,kCh] = a;
# Python code, fm size 5*3*10
a = np.zeros((3,10));
fm = [];

for kCh in range(5):
    fm.append(fm_val);

I implemented the matte wrap code above as follows.

Is there a way to expand an array that doesn't use append or extend?

I have to calculate the array, but the size changed when I used the phrase above, so the calculation value changed in the calculation value changed.

python array

2022-09-20 19:56

1 Answers

Please refer to the code below.

import numpy as np

a = np.zeros((3,10));
fm = np.zeros((3,10,5))

for kCh in range(5):
    fm[:,:,kCh]=a

print(fm)


2022-09-20 19:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.