These are four simple Matlab scripts/functions to get people started on MATLAB. It's from a little talk I gave for incoming Grad Students in the fall of 2006. I hope it's useful.
DISCLAIMER - I do not claim to be an expert on MATLAB but what little I have learned during the course of grad school here at Purdue I want to share. If its useful, great if not, sorry.
General Advice for Help on Matlab
If you need help, in order of usefulness
- Google it - this will sort 90% of your problems. If you are wondering if MATLAB can do something, chances are it probably can. So Google!
- Talk to a graduate student like me who has been around for years and is now considered part of the furniture in the department.
- If you are at Purdue AAE, go talk to Dr. Marc Williams - He is the resident expert on Matlab and coding in general - NOTE: this is a last resort as he is a busy man.
If Dr. Williams cannot help you then it's reasonable to assume that it cannot be done. So give up !!! Unless you are a glutton for punishment.TWO GENERAL COMMENTS
I am aware that I have referred to a matrix as a 2d vector. This is quite intentional as I want to emphasize that to be optimal and efficient while using MATLAB you need to understand the way it thinks. MATLAB sees every single matrix as a long stacked vector and it loves it when you understand that and code in that manner.
Some common commands to help you program with the above stated ideology are reshape, repmat, cat, find, : , squeeze.In general Matlab doesn't mind for loops as long as you allocate sufficient memory. In some extreme cases where you have to deal with a huge matrix such as 3000x3000 or more you can try to use vector operations. I have demonstrated this in the 2d example below but, it's tedious and not really worth it if you don't really deal with such big matrices.
Some commands to help you with that would be ones, zeros, eye
To get more info on any of the above commands you can type in help command_name in the MATLAB command window.
I have here four scripts to help you get started:
- 1D vector - works on a 1 d matrix and shows you four different ways of doing that.
- 2D vector - works on a 2 d matrix and shows you three different ways of doing that.
- Save plots - help for thesis writing, shows you how to automate plot generation - from font style and size to autosaving the generated figure. Also some advice on file formats for different purposes.
- Different plot example - just some different plot styles that MATLAB can handle
Some external links to useful MATLAB help
- University of Florida MATLAB tutorial
- MIT MATLAB help page
- UCSD MATLAB primer
- University of Utah MATLAB Basics
If you need any help on MATLAB, time and schedule permitting I will be happy to answer your questions or provide some direction if you shoot me an email. In the subject line please type in MATLAB help.
Joe Kline, our site specialist put together a useful tutorial on running MATLAB in the background. It's pretty useful if you don't want to clutter the memory of your PC while you are running something in MATLAB. Here is link to that - Running MATLAB in the background.And finally if there are any grammatical/spelling mistakes on this page - do you really expect someone who is so gung ho about MATLAB to worry about his grammar?
Prepared: Feb 2007 Ebenezer P Gnanamanickam (firstname.lastname@example.org)
Last Updated : March 13 2007