How do read .npy files in matlab?
881 次查看(过去 30 天)
显示 更早的评论
Juan Pablo Restrepo Uribe
2019-2-14
评论: MathWorks Supported Compilers Team
2024-9-11
Hello.
In matlab it is possible to read the extension .npy, or in its absence the extension .LVM of Labview.
0 个评论
采纳的回答
更多回答(4 个)
Toon Weyens
2021-2-16
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)
6 个评论
Cam Salzberger
2019-2-14
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
1 个评论
Johann Martinez
2022-2-23
One more reason to stop using Matlab. Python indeed has libraries to make use Matlab.
ROuntrance Krumph
2022-11-11
You cannot do so. MATLab® is proprietary software and cannot run "open-source" code .
It shall be destined to go the way of the Pheonix (Arizona)
size(IRIS); IRIS(size)
0 个评论
Grace Kepler
2023-11-7
Yes, use code like this.
>> x=py.numpy.load('data.npy')
2 个评论
Mike Jonson
2024-9-10
编辑:Mike Jonson
2024-9-10
No. That'd be how to do it with python, not in MATLAB.
MathWorks Supported Compilers Team
2024-9-11
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!