Reputation: 97
Currently, I have this piece of code to create a numpy array
X=np.array([[]]);
if (X.shape[1] == 0):
X = np.array([vd]);
else:
X = np.concatenate((X,np.array([vd])));
I would now like to get multiple numpy arrays X(1) , X(2) etc for different conditions. What is the best way to do this in python. In matlab I can accomplish this using matlab struct.
Upvotes: 2
Views: 3647
Reputation: 1121
I see @user3510686 has already answered it. Posing what I tried.
a={}
for i in range(10):
a[i]=np.random.rand(10)
Upvotes: 0
Reputation: 837
You can use a python dictionary for this purpose For example
import numpy as np
dic={}
dic['1']=np.zeros(3)
dic['2']=np.ones(5)
print dic['1']
print dic['2']
now dic['1'] and dic['2'] are you arrays
Upvotes: 1