Graphics Programs Reference
In-Depth Information
5. Write a script M-file that draws a bulls-eye pattern with a central circle
colored red, surrounded by alternating circular strips (annuli) of white
and black, say ten of each. Make sure the final display shows circles, not
ellipses. ( Hint : One way to color the region between two circles black is to
color the entire inside of the outer circle black and then color the inside of
the inner circle white.)
6. MATLAB has a function lcm that finds the least common multiple of
two numbers. Write a function M-file mylcm.m that finds the least com-
mon multiple of an arbitrary number of positive integers, which may be
given as separate arguments or in a vector. For example, mylcm(4, 5,
6) and mylcm([4 5 6]) should both produce the answer 60 . The pro-
gram should produce a helpful error message if any of the inputs are not
positive integers. ( Hint : For three numbers you could use lcm to find the
least common multiple m of the first two numbers and then use lcm again
to find the least common multiple of m and the third number. Your M-file
can generalize this approach.)
7. Write a function M-file that takes as input a string containing the name
of a text file and produces a histogram of the number of occurrences of each
letter from A to Z in the file. Try to label the figure and axes as usefully as
you can.
8. Consider the following linear programming problem. Jane Doe is running
for County Commissioner. She wants to personally canvass voters in the
four main cities in the county: Gotham, Metropolis, Oz, and River City.
She needs to figure out how many residences (private homes, apartments,
etc.) to visit in eachcity. The constraints are as follows:
(i) She intends to leave a campaign pamphlet at each residence; she
only has 50,000 available.
(ii) The travel costs she incurs for each residence are: $0.50 in each of
Gotham and Metropolis, $1 in Oz, and $2 in River City; she has
$40,000 available.
(iii) The number of minutes (on average) that her visits to each resi-
dence require are: 2 minutes in Gotham, 3 minutes in Metropolis,
1 minute in Oz, and 4 minutes in River City; she has 300 hours
available.
(iv) BecauseofpoliticalprofilesJaneknowsthatsheshouldnotvisitany
more residences in Gotham than she does in Metropolis and that
however many residences she visits in Metropolis and Oz, the total
of the two should not exceed the number she visits in River City;
(v) Jane expects to receive, during her visits, on average, campaign
contributions of: one dollar from eachresidence in Gotam, a
Search WWH ::




Custom Search