35

I have done a project in Matlab and now I have uninstalled Matlab. Now, I need some reference of my project. I'm left with all the .mat files. I'm trying to open them in notepad and I'm getting unicode characters over there. My question is simple. How do I open the Matlab code in .mat file into notepad or some word processor?

7
  • 1
    mat file is not ASCII so you cannot open it with notepad. You can try python though, check this: docs.scipy.org/doc/scipy-0.14.0/reference/generated/…
    – NKN
    Sep 12, 2014 at 14:32
  • 1
    You can open them with Octave. See this link: stackoverflow.com/questions/8099727/…
    – Benoit_11
    Sep 12, 2014 at 14:34
  • thanks for the response. but I'm not familiar with python editor and I dont have Octave . that's the problem Sep 12, 2014 at 14:38
  • 3
    Have you considered just downloading a trial version of MATLAB, reading the files, saving them to a text format, and uninstalling again? That might be easier than any of the other options. Sep 12, 2014 at 15:07
  • 1
    .m files are the files containing codes. They can be open with any text editor. .mat files contain data in a binary format which will vary with the version. Try other simpler options first (as given in comments and answers), but if all else fail, you can try to recover your data by digging directly into the .mat file programmatically : MAT file format
    – Hoki
    Sep 12, 2014 at 15:53

8 Answers 8

16

.mat files contain binary data, so you will not be able to open them easily with a word processor. There are some options for opening them outside of MATLAB:

If all you need to do is look at the files, you could obtain Octave, which is a free, but somewhat slower implementation of MATLAB. You can refer to How do you open .mat files in Octave? for more information on the subject. You can get octave from http://www.gnu.org/software/octave/download.html. The interface is very similar to MATLAB's.

As NKN and Ergodicity mentioned, there are python libaries available for this as well.

The most hardcore solution would be to write your own processor from scratch. The MAT file specification is available from MathWorks at http://www.mathworks.com/help/pdf_doc/matlab/matfile_format.pdf.

0
8

I didn't use it myself but heard of a simple tool (not a text editor) for this so it is definitely possible without setting up a programming environment (by installing octave or python).

A quick search hints that it was possible with total commander. (A lightweight tool with an easy point and click interface)

I would not be surprised if this still works, but I can't guarantee it.

2
4

A .mat-file is a compressed binary file. It is not possible to open it with a text editor (except you have a special plugin as Dennis Jaheruddin says). Otherwise you will have to convert it into a text file (csv for example) with a script. This could be done by python for example: Read .mat files in Python.

0
4

There's a really nice easy way to do this in Macintosh OsX. A fellow has made a quicklook plugin (command-space) that renders .mat formats so you can view the variables inside etc. Quite useful! https://github.com/jaketmp/matlab-quicklook/releases

3

Maybe MatFileViewer can be used to view mat file without matlab.

But it only supports 1D and 2D mat file.

2

If you are using the free software R, you can open the matlab files in Rstudio. Very easy!

0
2

You can simply go to the octave online website: https://octave-online.net/ Then upload your files there. and load them using load function as done with MATLAB

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 13, 2021 at 13:47
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review Oct 13, 2021 at 16:34
-1

You don't need to download any new software. You can use Octave Online to open .m files.

1
  • 2
    The question was about ".mat" files, which are binary.A ".m" (i.e. source file) can be opened with any text editor, even MS Word if you wish :-) Aug 12, 2020 at 8:37

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.