Welcome!
This is the TA website for CS101. It's intended both for those attending my lab sections, and for the class as a whole. This site is in heavy construction state at this time; it should become more interesting in a few days to a week.
Section AYI, Thursday 1 - 2:50.
Section AYJ, Thursday 3:00 - 4:50.
Office hours: TBD. For the first week, if you need me, I'll stay after lab, or email me to schedule some time.
First week overview is available here.
Labs notes and hints
This section will contain the most important things about each lab, intended both to help you do that lab, and to help you study for exam from the lab.
Week 1
- Some of you, especially those who are not engineering students, will find that they can't log in. If that's the case, just ask me and I should be able to solve this.
- If you see an error about MATLAB operator, try to think: what's an operator? The error message actually shows you precisely where the error is with a bar sign (|). What could you put there?
Week 2
- General. Any time you have a trouble with a MATLAB command, try asking it for help. Type
help commandname to see the help page for that command.
- Question 1. Try to understand what the bracket notation does (run some experiments like "['abc' 'def']" to see for yourself). Your job is to get the result without using the actual number "1.234" but by using the variable
number and the function num2str
- Question 18. Try to understand why this doesn't work. In general, any time you get an error message from MATLAB (red stuff starting with "???"), don't just ignore it but try to understand what it says. Some error messages are confusing, but others are informative. The vertical bar (|), if present, shows you the error location.
- Question 20. There are two separate issues here. First, understand the color notation. One colon (such as a:b) creates a vector of successive integer values between a and b. For example, 1:5 creates the vector 1 2 3 4 5. Two colons (a:b:c) create a vector of integers between a and c with step of b. That means the first value is a, second is a+b, third is a+2b, and so on until b.
The second issue is that of vector subscripting. If you have a vector y, saying y(2) will give you the second element of y, and saying y(z) where z is a vector will give you the vector of values that reside in y on positions that are values of z. This sounds confusing, but isn't. Here's an example. Let y be a vector 10 20 30 40 50. Then y(2) is 20, and y([3 4 1]) is a vector 30 40 10 - the vector of values that reside in y at locations 3, 4 and 1. Using end gives you the last element of the vector.
So now you have to use both of these facts to create a vector that has all elements of y in the flipped order. What vector defines positions of y in the opposite order? How can you create this vector?
- Question 31 and 32. Adapt the formulas from above to using x2 and y2.
- Question 36. If you get the error about being unable to plot because of different dimensions, this means that you can only plot two vectors against each other if they have the same number of elements. For example, you can plot 1 2 3 4 against 10 20 30 40, but not against 10 20 30. Make sure that the second argument to plot has the same number of elements as the first. Hint: look at the question 35.