How do read .npy files in matlab?
842 ビュー (過去 30 日間)
古いコメントを表示
Juan Pablo Restrepo Uribe
2019 年 2 月 14 日
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!