20 MATLAB commands you won't forget
clcclear the command window. Probably the best command of all time to reduce user anxiety.
clear allclear all variables in your workspace. Trust me you'll be using this one.
plot()Plot curves by inserting vectors of the same length in the function. Amazing.
subplot()Plot multiple figures in one window. Godlike.
axis([-1 1 -1 1])Set the minimum x and y axis of your plot. This can be set manually too.
legend('string')Name the data series of your figure. Pretty sweet!
shgDisplay the figure window instantaneously. No more frustrating clicks!
run directory/scriptnameRun another script within your script. Helps you keep it clean and organised.
load directory/workspacefileLoad variables saved from the workspace directly to your script.
help functionAccess the documentation on the usage of the function directly in your command window. This is the command I use the most in MATLAB by far!
length(vector)Returns the length of a vector. Very useful when using for loops.
size(matrix)Returns the size of a matrix. First thing I do when I get dimensioning error messages!
ones()Create a vector or a matrix of ones. This is awesome, forget building a vector like this: x=[1 1 1 1 1], just use ones(1,5) and you'r good.
zeros()Creates a vector or a matrix of zeros. Same principle here but with zeros!
rand()Create a random vector or a matrix. So convenient when you'r just goofing around or testing basic things.
disp('string')Display a string in the command window.
ticStart the invisible stopwatch.
tocStop the stopwatch and get information on the time elapsed! Useful if you want to know the duration of a simulation for example!
input()Prompt the user for an input. Can be very useful when using if conditions.
xlsread(directory/filename,sheet,range)Read a range of data from an excel sheet. Gaaah, this is for all of you who like me, thinks Excel is good for sorting data but terrible for presenting figures.
I hope you will find these commands helpful! There are tons of them out there and I do encourage you to take a look at the online documentation or just google some on your spare time. The more commands you learn the faster and more elegantly will you be able to solve your future homework assignments!