2

I just want to view the contents of the file. It's in a directory, which I have access to. Is there a Unix command to view the contents of it? I can also load it in MATLAB. Is there a similar MATLAB command?

Thanks

Amro
  • 123,847
  • 25
  • 243
  • 454
Josh
  • 21
  • 1
  • 1
  • 2
  • related question: http://stackoverflow.com/questions/4026690/check-if-field-exists-in-matlab-struct-without-loading-it – Amro Jan 17 '11 at 15:26

1 Answers1

4

To load myFile.mat from your home directory, start Matlab and call

load ~/myFile.mat

This loads the file into your workspace, and lets you inspect its contents.

If you have a more recent version of Matlab, you can also click on it in Matlab's directory browser, beneath which you see a preview of the contents (e.g. the variables it contains). Also, double-clicking on the file in Matlab's directory browser opens an import dialog.

Since more recent versions of Matlab save files in hdf5 format, you can open the file from the Unix commmand line with any tool that is capable of reading that format. However, opening it in Matlab is usually the more convenient option.

Jonas
  • 74,690
  • 10
  • 137
  • 177
  • Thanks for your help. I'm new to MATLAB. After I load the file in the workspace, how do I inspect its contents? I don't have a very recent version of Matlab. – Josh Jan 17 '11 at 03:29
  • 2
    Loading the file means copying the contents of the .mat file in to your workspace. If you say `clear` right before the load, then after the load the contents of your workspace will be the same as the contents of the .mat file. (If you don't say `clear` then any variables that exist before the load will still exist after the load, though they may be overwritten by the version in the .mat file.) – user57368 Jan 17 '11 at 06:21