Hello.
In matlab it is possible to read the extension .npy, or in its absence the extension .LVM of Labview.

 采纳的回答

Andrew Knyazev
Andrew Knyazev 2019-6-11
编辑:Walter Roberson 2024-12-20

14 个投票

5 个评论

I copied readNPY.m and readNPYheader.m from there and could then easily read npy-images into matlab.
Thankyou very much! /Maria
Excellent!! Thankyou very much...
Is it possible for you to show or briefly explain how to use this readNPY.m and readNPYheader.m/how to integrate this to our codes?
Best response from my point of view!

请先登录,再进行评论。

更多回答(3 个)

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 个评论

i tried this, it seems to work but it's asking me to allow_pickle=True
In my case I had to do something like this
X = np.load('./dataset/dataset_Xs.npy')
savemat('./dataset/dataset_Xs.mat', {'X': X})
This works. Thanks Leonardo :)
Help me greatly thank u
"the easiest thing would be to create a Python script such as the one below, and run that."
This is easier:

请先登录,再进行评论。

Grace Kepler
Grace Kepler 2023-11-7
编辑:Stephen23 2024-12-20
Yes, use code like this.
x = py.numpy.load('data.npy')

3 个评论

No. That'd be how to do it with python, not in MATLAB.
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

请先登录,再进行评论。

Cam Salzberger
Cam Salzberger 2019-2-14

1 个投票

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 个评论

One more reason to stop using Matlab. Python indeed has libraries to make use Matlab.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Call Python from MATLAB 的更多信息

产品

版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by