How to remove Headers convert to ENVI - Idiot's Guide Required

1 view (last 30 days)
Dear all,
First, a qualifier - I have never used Matlab before and am struggling with getting started. I am going on a course to cover the basics and have been looking at some online tutorials. However, what I require is assistance/advice on getting started with a specific protocol that I will need to carry out.
Namely - the conversion of a .mat file to a .envi file. The previous researcher advised that I would need to "remove headers" from the .mat file and then use some writenvi matlab code. Unfortunately, I am struggling to even open and remove the headers from the file!
Any "idiots guide" style advice would be greatly appreciated.
Best,
Jen

Answers (2)

Star Strider
Star Strider on 23 Oct 2012
You'll find MATLAB easy to learn if you have experience with other programming languages. I admit to not knowing anything about envi files, so I did a short search and discovered that you may need multibandread and multibandwrite to work with them. There are also some MATLAB Central File Exchange contributions that deal with envi files.
For information on MATLAB files in general, see Supported File Formats. It's a reference, not a tutorial, but it will help you understand the files MATLAB can work with, and has links to related functions. You might also want to refer to Process a Sequence of Files later.
  2 Comments
Jennifer
Jennifer on 24 Oct 2012
Thanks Star Strider. I'll take a look at those resources. I haven't worked with programming languages in the past so it's all new to me. I'm looking forward to learning and becoming more generally proficient at it but need, fairly urgently, to be able to do this particular protocol. Most of the tutorials help with the basics but don't really address a specific protocol (which is really all I need at this stage).
Star Strider
Star Strider on 24 Oct 2012
Edited: Star Strider on 24 Oct 2012
Here is the index to MATLAB documentation. Apparently, you are inheriting a number of scripts (MATLAB program files), so I suggest you take some time to study them to see what they do and how they work. MATLAB has varied over the years in how it works, so what I write applies to the most recent version, 2012b on Windows 7.
The first thing you will need to learn is how to use the Editor to Open and Save Files.
While you are going through the code your already have (using the MATLAB Editor), and if you want to know what a particular command or function does, put the cursor on the command, left-click, and either press F1 or right-click and click on Help on Selection in the menu that pops up. That will open a documentation ‘help’ window about that particular command or function. (This is a lot easier than going through the documentation and searching for it.) You can also use that same window to search the documentation for any other command or function.
MATLAB is a ‘safe’ language in that in the normal course of programming it is very difficult to crash your computer or do any significant damage, so don't be afraid to experiment with your own program scripts as you learn MATLAB. If a program seems to be taking a long time, press ‘CTRL’ and ‘C’ at the same time. That will interrupt any MATLAB script or function you are currently running, and return control to the Command Window.

Sign in to comment.


Walter Roberson
Walter Roberson on 23 Oct 2012
.mat files do not have headers. Perhaps you are dealing with a text file instead of a (binary) .mat file?
  2 Comments
Jennifer
Jennifer on 24 Oct 2012
Thanks Walter. It's definitely a .mat file as I export it from my instrument in that format. That's where I suspect that the "headers" come from? If I save it as a .m and open it with "import data", I can see some "header" type information at the top of the import screen but I am unable to delete it and there is too much data to view in the variables screen in matlab if I try to open it directly from the .mat format so I don't know if it's there in the .mat file or not.
Really it's a bit of a nightmare. I can't go on a course until Jan but need to start processing data now.
Walter Roberson
Walter Roberson on 24 Oct 2012
Have you tried to use load() on the .mat file, and then use the Workspace Browser tool to examine the variables?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!