If you're a complete matlab novice, type "intro" or, if you're real fond of splashy colors, type "demo". You can also read help from matlab help menu.
You can also type "helpwin" or "helpdesk" to get a help window. The matlab help command is "help". Try "help general" or just plain "help". The apropos command is "lookfor". Try, e.g. "lookfor tangent" or "lookfor random".
The matlab comment character is "%". The semicolon ";" is useful too; it makes the command on that line operate silently. For example, "A = B;" copies matrix B into matrix A. "A = B" does the same thing, but prints out the whole contents of matrix B while copying.
sprintf sscanf num2str int2strMatlab5 and 6 added the very useful "cell array" and "struct" data types. A cell array is just like a matrix except each entry can be any data type, not just a number. For example:
>> c = {'joe' 5 [1 2 3]} c = 'joe' [5] [1x3 double] >> c{3} ans = 1 2 3A struct is similar except its contents are addressable by name only.
>> s = struct('name', 'joe', 'age', 30) s = name: 'joe' age: 30 >> s.name ans = joe >> s.age ans = 30
plot grid hold drawnow axis axes orient subplot mesh meshgrid plot3 rotate3dThen you'll want to print your plot to a file. To print the current plot to a postscript file, type
orient tall %% this line is optional print -deps myfilename.psYou can use C style file I/O. Get help on commands
fopen fclose fscanf fprintf printfThe matlab parser is not too clever, so don't put "-" in a filename; poor matlab will think you want to subtract!
Matlab has a native data file format, plus it can save and load data from ASCII files. See the stock answers and check out
save filename.dat -ascii load filename
In matlab, subroutines can be associated with specific classes to simulate "methods" for object-orientation. To make a method for class myclass, all you have to do is put the subroutine in a subdirectory called @myclass.
You must always have a subroutine in @myclass which is just called myclass. This subroutine is called to create instances of the class. Get matlab's help on class. If you redefine a class, e.g. by editing @myclass/myclass, Matlab will complain unless you clear the old definition with clear myclass. Don't ask me why.
clear x can also be used to remove the variable x from the workspace, e.g. to reclaim memory. Careful: clear alone removes all variables!