How do read .npy files in matlab?
590 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Juan Pablo Restrepo Uribe
el 14 de Feb. de 2019
Hello.
In matlab it is possible to read the extension .npy, or in its absence the extension .LVM of Labview.
1 comentario
Respuesta aceptada
Andrew Knyazev
el 11 de Jun. de 2019
Editada: Walter Roberson
el 20 de Dic. de 2024 a las 7:14
5 comentarios
Más respuestas (3)
Toon Weyens
el 16 de Feb. de 2021
If you have access to Python, the easiest thing would be to create a Python script such as the one below, and run that. It will find all .npz files in the current directory and convert that to .mat.
from scipy.io import savemat
import numpy as np
import glob
import os
npzFiles = glob.glob("*.npz")
for f in npzFiles:
fm = os.path.splitext(f)[0]+'.mat'
d = np.load(f)
savemat(fm, d)
print('generated ', fm, 'from', f)
7 comentarios
Stephen23
el 20 de Dic. de 2024 a las 9:16
"the easiest thing would be to create a Python script such as the one below, and run that."
This is easier:
Cam Salzberger
el 14 de Feb. de 2019
Hello Juan,
I don't believe that either of those file formats are natively supported in MATLAB, but you can always check File Exchange to see if anyone has written an importer for them. A quick search did not turn up anything for NPY, but LVM turned up this one. If you have any questions about that File Exchange package, it's best to direct them to the author of the package.
-Cam
2 comentarios
Johann Martinez
el 23 de Feb. de 2022
One more reason to stop using Matlab. Python indeed has libraries to make use Matlab.
Grace Kepler
el 7 de Nov. de 2023
Editada: Stephen23
el 20 de Dic. de 2024 a las 9:31
Yes, use code like this.
x = py.numpy.load('data.npy')
3 comentarios
MathWorks Supported Compilers Team
el 11 de Sept. de 2024
Hi Mike,
Did you try it? This works for me. Note that "py." is prepended to the normal Python command "numpy.load('data.npy')".
>> x=py.numpy.load('data.npy')
x =
Python ndarray:
1 2 3
4 5 6
7 8 9
Stephen23
el 20 de Dic. de 2024 a las 6:36
"No. That'd be how to do it with python, not in MATLAB."
No, that is how to do it from MATLAB, not from Python:
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!