import numpy as np rand_array = np.random.rand(1,10); np.save('rand.npy',rand_array); b=np.load('rand.npy');
This example shows how to save an array in a .npy file and then load. This save/load function is quite similar to the save/load in Matlab except for that Matlab allows saving multiple arrays in single file while in Python one file can hold only one array. For comparison purpose, Matlab save/load code is shown below where two arrays with random numbers are save in the same file
rand_array=rand(1,10); rand_array2 = rand(1,10); save('rand_file','rand_array','rand_array2'); myFile = load('rand_file');
No comments:
Post a Comment