Due: Tuesday, March 22
Under linux Matlab is started using the command "matlab". There is both a GUI and an non-GUI interface. The GUI requires that X-windows is working properly, and is a bit slow. The non-GUI version can be started up with: "matlab -nodisplay -nojm". If your DISPLAY variable is not set correctly, you will get the non-GUI version by default.
Recommend machines to use are cy01, cy02, cy03, ..., cy10. To use onto these remotely, you will have to login to lectura first (lectura.cs.arizona.edu), and then ssh from there. Matlab is NOT available on lecture itself.
If you are having trouble, get support from your group. If you are still having trouble, E-mail kobus@cs.arizona.edu. Start early to leave time for iterating over problems and don't beat your head against the wall!
Read this short Matlab tutorial and be aware of this longer Matlab primer. Google can be used to find other tutorials.
The
complete
documentation for Matlab is also available on the web.
All Matlab commands are well documented with
Matlab's help system. For example, if you want to know how the
svd
function works, type help
svd
. You can also get help on all the built in operators
and even the language itself. Typing help
gives a list of help topics.
Tip: You may want to turn on paging (more on
) for reading help pages.
Tip: Often you want to put a semicolon at the end of your directives to Matlab. The semicolon at the end of a line prevents Matlab from displaying the result of an expression.
Download
this file
into your working directory
and read it into matlab matrix
x = load('data_a1_1.txt')
Compute the mean and the sample standard error of each column of the matrix
Too easy? For those who program all the time: Can your solution be easily modified for the case that the amount of data (the number of rows in the matrix) is too big to fit in memory and/or all you can do is read the rows of x one at a time, and you can only read them once (i.e. no rewind)?
The previous calculation assumed that each data point was equally important. When doing probabilistic calculations, we want to deal with quantities in accordance with the probability that we believe them. Those probabilities become weights which we use to multiply the effect of each point. The weights (like probabilities) should sum to one.
For this exercise, compute the same quantities as in the previous question, but weight each row by the row number. Thus row 1 gets weight 1, row 2 gets weight 2, etc. Of course, the weights as stated do not add up to one. You need to deal with this.
If this is giving you trouble, after a fair attempt, click here for a hint.
x=rand(4)
gives you a random matrix with entries between 0 and 1. The directive:
y=x'Computes the transpose of x. Finally, to invert x:
z = inv(x)
Generate a random matrix and compute the different of these two quantities:
the inverse of the transpose the transpose of the inversethereby reminding yourself of the fact that they are the same, quicker than you might be able to find it in a text or prove it.