User Tools

Site Tools


gibson:teaching:spring-2015:math445:hw2

**This is an old revision of the document!** ----

A PCRE internal error occured. This might be caused by a faulty plugin

====== Math 445 HW 2: array operations and basic plotting ====== Helpful Matlab functions sum, any, all, linspace plot, semilogy, semilogx, xlabel, ylabel, legend, axis, hist, randn **Problem 1:** Write a Matlab expression that sums the first N of each series and evaluate it for N=100. (a) 1 + 1/2 + 1/3 + 1/4 + ... \\ (b) 1 + 1/2 + 1/4 + 1/8 + ... \\ %%(c)%% 1 + 1/3 + 1/9 + 1/27 + ...\\ (d) 1/2 + 2/3 + 3/4 + 4/5 + ...\\ (e) 1/2 - 2/3 + 3/4 - 4/5 + ...\\ **Problem 2:** A theater has a seating capacity of 900 and charges %%$%%2.50 for children, %%$%%4 for students, and %%$%%5.50 for adults. At a certain screening with full attendance, there were half as many adults as children and students combined. The total money brought in was %%$%%3825. How many children, students, and adults attended the show? **Problems 3-9:** Turn in the Matlab code and the figures. Always label the figures appropriately, using ''title'', ''xlabel'' and either ''ylabel'' or ''legend''. The figures should be titled "Problem 5", etc. Read ''help'' for the following functions and then experiment with them to see how they affect the plot. figure, clf, hold on, hold off grid, xticks, yticks axis([xmin xmax ymin ymax), axis equal, axis square randn, hist **Problem 3:** Plot sin(x) versus x for 100 evenly space points in x from 0 to 2pi, using a solid blue line. **Problem 4:** Plot sin(x) in red, cos(x) in green, over same x as problem 5. Use 'legend' to indicate which function is shown in which color. **Problem 5:** Plot $y = 5x^2 - 4x - 3$ for 40 evenly space points in x from -2 to 2, using a red line and a circle on each data point. Superimpose an x,y grid on the plot. **Problem 6:** Make a plot of the unit circle. Make sure it's closed --no gap! Hint: use ''linspace'' to specify a range of angles, then ''cos'' and ''sin'' to produce vectors of the x,y coordinates of points on the unit circle. **Problem 7:** Plot $10^{3x}$ for 100 points x evenly space between -2 and 5. Choose the most appropriate plotting function. Hint: it ain't ''plot''! **Problem 8:** Plot $3 x^5$ for 100 points x evenly space between 1 and 4. Choose the most appropriate plotting function. Again, it ain't ''plot''! **Problem 9:** Make a histogram of 1000 random numbers from a normal (Gaussian) distribution. Use Matlab's ''hist'' and ''randn'' functions.

gibson/teaching/spring-2015/math445/hw2.1424032892.txt.gz · Last modified: 2015/02/15 12:41 by gibson