Professional Documents
Culture Documents
02IS at ESG
Fall 2003
we may want to divide by r = x2 + y 2 , and we need to stay away from the origin. To see what weve done so far, enter >>whos and see that while the variables xx and yy are 1 41 arrays, the variables x and y are 41 41 arrays. That is, both x and y have been dened at each grid point. So, lets plot something. Dene a function r by >>r = x.^2+y.^2; (yes, I know this should be r 2 , but its not worth messing with the variable names). The dot after both the x and y is crucial; this tells MATLAB to perform the operations term-by-term, intstead of mutiplying the matrices corresponding to the array. The basic commands to plot are then >>mesh(r) or >>plot3(x,y,r) and you will want to plot both to see which you prefer and why. Now, get fancy. Try >>z = x.*y.*(x.^2-y.^2)./r to dene an interesting function. Note that you need a dot for each operation. Plot this function as before, with >>mesh(z) or >>plot3(x,y,z) to get your own version of the 18.023-ESG Logo.