Questions tagged [mat-file]

Use with questions about .mat files. These files are used for storing MATLAB variables.

MAT-file is binary file format, used to store data in multiple variables or structures in MATLAB. These files use the .mat extension, and can be accessed in using the load, save or matfile functions. For more information, see MAT-File Versions in the MATLAB documentation.

MAT-files can be also created and read by other programming languages such as Python etc.

Refer to this PDF document for a description of the internals of the MAT-file format (Level 4 and Level 5).

218 questions
2
votes
1 answer

MATLAB-files with custom extensions

In MATLAB, I would like to be able to save (and re-open) MATLAB-files using a different extension than .mat (e.g. 'file.settings' / 'file.data' / etc.) so that, e.g., the file 'file.settings' is really a 'file.mat' in disguise. How can this be…
spreus
  • 108
  • 6
2
votes
1 answer

Scipy loadmat only load integers?

It seems that I can only load everything as uint8 type, just with the following two lines, import scipy.io X1=scipy.io.loadmat('one.mat') all double precision numbers get transformed. What should I do?
mayasky
  • 1,025
  • 1
  • 9
  • 9
2
votes
2 answers

Why does SciPy's loadmat throw a MemoryError when reading a 200 MB Matlab struct

I'm using the following code to try to load a MAT file in Python. I can load it without issue in MATLAB. from scipy.io import loadmat test_filename = 'test_data.mat' #This is a struct data =loadmat(test_filename, struct_as_record=True) Running…
mac389
  • 3,004
  • 5
  • 38
  • 62
2
votes
3 answers

ndim in numpy array loaded with scipy.io.loadmat?

Using SciPy and MATLAB, I'm having trouble reconstructing an array to match what is given from a MATLAB cell array loaded using scipy.io.loadmat(). For example, say I create a cell containing a pair of double arrays in MATLAB and then load it using…
Erik Kastman
  • 528
  • 6
  • 17
1
vote
1 answer

Creating a Three Dimensional Matrix structure and writing in mat file in Python

I am very new to Python. I need to have a 3 dimensional matrix, in order to save 8 by 8 matrix in some length. Let's call 530. The problem is that I used np.array since matrix cannot have more than 2 dimensions as numpy argues. R =…
Hephaestus
  • 43
  • 1
  • 5
1
vote
1 answer

Reading mat file in python

I use h5py to read a mat file but the size of the loaded file is not the same as the size of the matrix in matlab. My matrix with the name of the 'u' has the size of (155,142,5000) in matlab but when I load the file in python, its size is 110050000…
1
vote
0 answers

How to export datasets to .csv file from the field variables stored in .mat files

I am trying to import the data from a complex .mat file where 4 fields variables are stored. I need to store the field variables (dataset one) in csv format. I am unable to store the data. import scipy.io # to load mat files import seaborn as…
Martin
  • 11
  • 1
1
vote
0 answers

How to convert .mat Matlab file to nii.gz Nifti file?

I have a .mat file, the size of which is 512x512x251. How can I convert .mat Matlab file to nii.gz Nifti file? Given that I'm not available for Matlab program, I want to do it with python. What I want to do is 10000130.mat -> 10000130.nii.gz
Sando
  • 11
  • 3
1
vote
1 answer

How to read a .mat file table of contents?

I have a Matlab .mat file for table of contents and I want to extract it using Python. I am using scipy.io.loadmat but the data is not being extracted. It shows None and matlabopaqe,mcos. I have uploaded the .mat file here. import scipy.io from…
1
vote
0 answers

Reading .mat file in R

I am unable to parse a list of values read from a.mat file. library('rmatio') eyes_open <- read.mat('Documents/TE/Implementation/DP23EyesOpen.mat') print(str(eyes_open)) Running the script above produces: $ mat1: num [1:30, 1:2000] -0.567 -0.54…
AnonymousMe
  • 509
  • 1
  • 5
  • 18
1
vote
1 answer

Exception thrown at exact same location on each build in C++ when trying to write .mat file

I am trying to write .mat files using C++. I am using Microsoft Visual Studio 2019 along with Qt to develop my application. MainWindow.h #include #include "ui_mainwindow.h" #include "mat.h" class MainWindow : public…
Chaitanya
  • 177
  • 2
  • 9
1
vote
1 answer

How to load a matlab MAT file from memory?

Let's say I have an array of the bytes of a mat file loaded into my Matlab shell. One way to parse this data is to write it to the disk, and then use Matlab load function. Is there a way to do that without writing to the hard drive (on windows)? I…
Dani
  • 73
  • 8
1
vote
2 answers

How to convert .mat binary format to 2D numpy array?

I'm converting hand_dataset annotations to such a format I could use it in YOLOv3. Annotations are in .mat binary format and I want to extract it, convert and reorganize in .csv. I have tried mat = scipy.io.loadmat(file), but extracting data goes in…
1
vote
1 answer

save the spectrogram as a mat file

I used the spectrogram function in MATLAB to generate spectrogram and save it as a mat file directly. Then, I used the same wav file and the same way to generate another spectrogram. But I saved it as a jpg file first and the saved the jpg file as…
yunyang
  • 43
  • 4
1
vote
1 answer

How to save a figure in a MAT-file?

I want to save the image in a figure directly as a 256x256 size MAT-file. However, I found that the saved MAT-file sizes were different, and when using imagesc to display the image, it seemed to be a little different from the original image. I will…
yunyang
  • 43
  • 4