How do read .npy files in matlab?
조회 수: 860 (최근 30일)
이전 댓글 표시
Hello.
In matlab it is possible to read the extension .npy, or in its absence the extension .LVM of Labview.
댓글 수: 1
채택된 답변
추가 답변 (3개)
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)
댓글 수: 7
Stephen23
2024년 12월 20일
"the easiest thing would be to create a Python script such as the one below, and run that."
This is easier:
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
댓글 수: 2
Johann Martinez
2022년 2월 23일
One more reason to stop using Matlab. Python indeed has libraries to make use Matlab.
Grace Kepler
2023년 11월 7일
편집: Stephen23
2024년 12월 20일
Yes, use code like this.
x = py.numpy.load('data.npy')
댓글 수: 3
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
Stephen23
2024년 12월 20일
"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:
참고 항목
카테고리
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!