??? Error using ==> mpower
Matrix must be square.
x=-100:.1:100; f=((x.^2)-4)/(x+2); plot(x,f) title('Some title') xlabel('X Axis') ylabel('Y Axis') |
A1: please include the plots as well with the homework. You may have more than one plot per page to save paper, just label in the title the plot, and refer to the appropriate label for a problem. Example: a plot which has the title 'problem 3.2.1 : x vs. y'
A2: remember to use the . operator when performing multiplication or division involving two variables or raising a variable to a power (example: x.^2, x.*y, or x./y). You do not need to use the . operator when multiplying a scalar, or subtracting or adding numbers and vectors (example: 5*x, or x+y, or x+5). See the plotting examples for m file examples of this.
A3: Square brackets. The curly braces were merely being consistent with mathematical notation to the literature. But in matlab, curly braces have a specific meaning. If you used curly braces you would be getting errors. The following is from the matlab help documentation:
{ } Braces are used to form cell arrays. They are similar to brackets [ ] except that nesting levels are preserved. {magic(3) 6.9 'hello'} is a cell array with three elements. {magic(3),6.9,'hello'} is the same thing. {'This' 'is' 'a';'two' 'row' 'cell'} is a 2-by-3 cell array. The semicolon ends the first row. {1 {2 3} 4} is a 3 element cell array where element 2 is itself a cell array. Braces are also used for content addressing of cell arrays. They act similar to parentheses in this case except that the contents of the cell are returned. Some examples: [ ] Brackets are used in forming vectors and matrices. |
A4: In response to your questions,
1) problem 3.1.5 yes it should be x=-2 as in that's where the discontinuity is, and the question is to explain why. It has to do with the denominator going to zero. Check your old calc/precalc books for limits and continuity or discontinuity, or look on mathworld, or another similar site (google is our friend:)
I see in the code you sent the reason it's coming out with one number: don't forget the '.' before the division ('/'), as you want to divide element-wise (as opposed to as a vector operation).
A5: Just compute this by hand. You can do this symbolically in matlab using the sym command, but I didn't go over that and don't expect that of you. If you are interested in computing the answer symbolically in matlab (ie you end up with some combination of x1 and x2), the help documentation about symbolic manipulation is pretty good (help sym). Once you create a symbolic object you can have matlab simplify equations and perform multiplications symbolically (ie not with a specific number, just with symbols like x1, x2).
A6: See handouts section, example 3 plotting code. I introduced it in class briefly and discussed it, but I think the subplot command is tricky at first, it's one of those things that makes sense once you do it.
A7: you could create a stepsize which will avoid that point, or you could create two arrays which don't quite include -1, then put them together...x=[-100:-.1, .1:100];